JWS-96 initial code for the stat crawler
[jabaws.git] / webservices / compbio / stat / collector / StatDB.java
index 32b7fde..45947a2 100644 (file)
@@ -53,6 +53,10 @@ public class StatDB {
        static Connection conn;\r
 \r
        private synchronized static Connection getDBConnection() throws SQLException {\r
+               return getDBConnection(statDBName);\r
+       }\r
+\r
+       private synchronized static Connection getDBConnection(String dbname) throws SQLException {\r
 \r
                if (conn != null && !conn.isClosed()) {\r
                        return conn;\r
@@ -64,7 +68,7 @@ public class StatDB {
                                // Apparently under Tomcat webapp you cannot rely on Java\r
                                // auto discovery and have to register the driver explicitly\r
                                Class.forName(driver);\r
-                               conn = DriverManager.getConnection(protocol + statDBName + ";create=false");\r
+                               conn = DriverManager.getConnection(protocol + dbname + ";create=false");\r
 \r
                                conn.setAutoCommit(true);\r
                        } catch (ClassNotFoundException e) {\r
@@ -74,6 +78,11 @@ public class StatDB {
                return conn;\r
        }\r
 \r
+       \r
+       public StatDB(String dbname) throws SQLException {\r
+               this.conn = getDBConnection(dbname);\r
+       }\r
+\r
        public StatDB() throws SQLException {\r
                this.conn = getDBConnection();\r
        }\r