diff flys-backend/src/main/java/de/intevation/flys/backend/SedDBCredentials.java @ 5193:fb9dcc68b9c2

Possible fix for flys/1202. Initial SQL statements can now be issued at connection creation.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 07 Mar 2013 17:39:25 +0100
parents 76c75c8b9ee0
children 92c8f8d1a3ba
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SedDBCredentials.java	Thu Mar 07 16:06:44 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/SedDBCredentials.java	Thu Mar 07 17:39:25 2013 +0100
@@ -73,6 +73,9 @@
     public static final String XPATH_URL =
         "/artifact-database/seddb-database/url/text()";
 
+    public static final String XPATH_CONNECTION_INIT_SQLS =
+        "/artifact-database/seddb-database/connection-init-sqls/text()";
+
     public static final String DEFAULT_USER =
         System.getProperty("flys.seddb.user", "seddb");
 
@@ -94,6 +97,10 @@
             "flys.seddb.url",
             "jdbc:postgresql://localhost:5432/seddb");
 
+    public static final String DEFAULT_CONNECTION_INIT_SQLS =
+        System.getProperty(
+            "flys.seddb.connection.init.sqls");
+
     public static final Class [] CLASSES = {
         BezugspegelgewId.class,
         Bezugspegelgew.class,
@@ -159,9 +166,10 @@
         String password,
         String dialect,
         String driver,
+        String connectionInitSqls,
         String url
     ) {
-        super(user, password, dialect, driver, url, CLASSES);
+        super(user, password, dialect, driver, url, connectionInitSqls, CLASSES);
     }
 
     public static synchronized Credentials getInstance() {
@@ -176,9 +184,13 @@
                 Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER);
             String url =
                 Config.getStringXPath(XPATH_URL, DEFAULT_URL);
+            String connectionInitSqls =
+                Config.getStringXPath(
+                    XPATH_CONNECTION_INIT_SQLS,
+                    DEFAULT_CONNECTION_INIT_SQLS);
 
             instance = new SedDBCredentials(
-                user, password, dialect, driver, url);
+                user, password, dialect, driver, connectionInitSqls, url);
         }
         return instance;
     }
@@ -189,7 +201,8 @@
             DEFAULT_PASSWORD,
             DEFAULT_DIALECT,
             DEFAULT_DRIVER,
-            DEFAULT_URL);
+            DEFAULT_URL,
+            DEFAULT_CONNECTION_INIT_SQLS);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org