From: pvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Date: Mon, 12 Dec 2011 14:46:33 +0000 (+0000)
Subject: load the driver explicitly
X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=af761a5bb8fb0f1fa5f4d8ae8cb245050c3aab59;p=jabaws.git

load the driver explicitly

git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4813 e3abac25-378b-4346-85de-24260fe3988d
---

diff --git a/webservices/compbio/stat/collector/StatDB.java b/webservices/compbio/stat/collector/StatDB.java
index 7073fc1..b469c44 100644
--- a/webservices/compbio/stat/collector/StatDB.java
+++ b/webservices/compbio/stat/collector/StatDB.java
@@ -58,19 +58,26 @@ public class StatDB {
 		if (conn != null && !conn.isClosed()) {
 			return conn;
 		} else {
-			String dbpath = PropertyHelperManager.getLocalPath();
-			log.info("Looking for JABAWS access statistics database at: "
-					+ dbpath);
-			System.setProperty("derby.system.home", dbpath);
-			conn = DriverManager.getConnection(protocol + statDBName
-					+ ";create=false");
-
-			conn.setAutoCommit(true);
-			/*
-			 * Runtime.getRuntime().addShutdownHook(new Thread() {
-			 * 
-			 * @Override public void run() { shutdownDBServer(); } });
-			 */
+			try {
+				String dbpath = PropertyHelperManager.getLocalPath();
+				log.info("Looking for JABAWS access statistics database at: "
+						+ dbpath);
+				System.setProperty("derby.system.home", dbpath);
+				// Apparently under Tomcat webapp you cannot rely on Java
+				// auto discovery and have to register the driver explicitly
+				Class.forName(driver);
+				conn = DriverManager.getConnection(protocol + statDBName
+						+ ";create=false");
+
+				conn.setAutoCommit(true);
+				/*
+				 * Runtime.getRuntime().addShutdownHook(new Thread() {
+				 * 
+				 * @Override public void run() { shutdownDBServer(); } });
+				 */
+			} catch (ClassNotFoundException e) {
+				log.error(e.getMessage(), e);
+			}
 		}
 		return conn;
 	}