From af761a5bb8fb0f1fa5f4d8ae8cb245050c3aab59 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Mon, 12 Dec 2011 14:46:33 +0000 Subject: [PATCH] load the driver explicitly git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4813 e3abac25-378b-4346-85de-24260fe3988d --- webservices/compbio/stat/collector/StatDB.java | 33 ++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) 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; } -- 1.7.10.2