From 430553b263c6c20b20978f418d2112a9002bd97a Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Thu, 26 May 2011 17:16:01 +0000 Subject: [PATCH] git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4179 e3abac25-378b-4346-85de-24260fe3988d --- webservices/compbio/stat/collector/StatDB.java | 10 ++++++++-- webservices/compbio/stat/servlet/AnnualStat.java | 2 +- webservices/compbio/stat/servlet/DisplayStat.java | 6 +++--- webservices/compbio/stat/servlet/Joblist.java | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/webservices/compbio/stat/collector/StatDB.java b/webservices/compbio/stat/collector/StatDB.java index 40f9d08..55bf71a 100644 --- a/webservices/compbio/stat/collector/StatDB.java +++ b/webservices/compbio/stat/collector/StatDB.java @@ -49,10 +49,16 @@ public class StatDB { + ";create=false"); conn.setAutoCommit(true); + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + shutdownDBServer(); + } + }); } return conn; } - public StatDB() throws SQLException { this.conn = getDBConnection(); } @@ -282,7 +288,7 @@ public class StatDB { st.close(); } - public void shutdownDBServer() { + private static synchronized final void shutdownDBServer() { // ## DATABASE SHUTDOWN SECTION ## /*** * In embedded mode, an application should shut down Derby. Shutdown diff --git a/webservices/compbio/stat/servlet/AnnualStat.java b/webservices/compbio/stat/servlet/AnnualStat.java index 9176db5..c25280c 100644 --- a/webservices/compbio/stat/servlet/AnnualStat.java +++ b/webservices/compbio/stat/servlet/AnnualStat.java @@ -34,8 +34,8 @@ public class AnnualStat extends HttpServlet { dispatcher.forward(req, resp); } catch (SQLException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServletException(e); } } diff --git a/webservices/compbio/stat/servlet/DisplayStat.java b/webservices/compbio/stat/servlet/DisplayStat.java index a235f7e..79d984f 100644 --- a/webservices/compbio/stat/servlet/DisplayStat.java +++ b/webservices/compbio/stat/servlet/DisplayStat.java @@ -39,16 +39,16 @@ public class DisplayStat extends HttpServlet { req.setAttribute("statTotalLocal", Totals.sumStats(stats.getLocalStat())); - req.setAttribute("startDate", fromDate.getTime()); - req.setAttribute("stopDate", toCal.getTime().getTime()); + req.setAttribute("startDate", fromDate); + req.setAttribute("stopDate", toCal.getTime()); System.out.println(fromDate + " " + toCal.getTime()); RequestDispatcher dispatcher = req .getRequestDispatcher("statpages/Statistics.jsp"); dispatcher.forward(req, resp); } catch (SQLException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServletException(e); } } diff --git a/webservices/compbio/stat/servlet/Joblist.java b/webservices/compbio/stat/servlet/Joblist.java index 7328e28..1b73018 100644 --- a/webservices/compbio/stat/servlet/Joblist.java +++ b/webservices/compbio/stat/servlet/Joblist.java @@ -135,7 +135,7 @@ public class Joblist extends HttpServlet { } catch (SQLException e) { e.printStackTrace(); throw new ServletException("SQLException : " - + e.getLocalizedMessage()); + + e.getLocalizedMessage(), e); } } -- 1.7.10.2