git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4179 e3abac25...
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 26 May 2011 17:16:01 +0000 (17:16 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 26 May 2011 17:16:01 +0000 (17:16 +0000)
webservices/compbio/stat/collector/StatDB.java
webservices/compbio/stat/servlet/AnnualStat.java
webservices/compbio/stat/servlet/DisplayStat.java
webservices/compbio/stat/servlet/Joblist.java

index 40f9d08..55bf71a 100644 (file)
@@ -49,10 +49,16 @@ public class StatDB {
                                        + ";create=false");\r
 \r
                        conn.setAutoCommit(true);\r
+\r
+                       Runtime.getRuntime().addShutdownHook(new Thread() {\r
+                               @Override\r
+                               public void run() {\r
+                                       shutdownDBServer();\r
+                               }\r
+                       });\r
                }\r
                return conn;\r
        }\r
-\r
        public StatDB() throws SQLException {\r
                this.conn = getDBConnection();\r
        }\r
@@ -282,7 +288,7 @@ public class StatDB {
                st.close();\r
        }\r
 \r
-       public void shutdownDBServer() {\r
+       private static synchronized final void shutdownDBServer() {\r
                // ## DATABASE SHUTDOWN SECTION ##\r
                /***\r
                 * In embedded mode, an application should shut down Derby. Shutdown\r
index 9176db5..c25280c 100644 (file)
@@ -34,8 +34,8 @@ public class AnnualStat extends HttpServlet {
                        dispatcher.forward(req, resp);\r
 \r
                } catch (SQLException e) {\r
-                       // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
+                       throw new ServletException(e);\r
                }\r
        }\r
 \r
index a235f7e..79d984f 100644 (file)
@@ -39,16 +39,16 @@ public class DisplayStat extends HttpServlet {
                        req.setAttribute("statTotalLocal",\r
                                        Totals.sumStats(stats.getLocalStat()));\r
 \r
-                       req.setAttribute("startDate", fromDate.getTime());\r
-                       req.setAttribute("stopDate", toCal.getTime().getTime());\r
+                       req.setAttribute("startDate", fromDate);\r
+                       req.setAttribute("stopDate", toCal.getTime());\r
                        System.out.println(fromDate + "  " + toCal.getTime());\r
                        RequestDispatcher dispatcher = req\r
                                        .getRequestDispatcher("statpages/Statistics.jsp");\r
                        dispatcher.forward(req, resp);\r
 \r
                } catch (SQLException e) {\r
-                       // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
+                       throw new ServletException(e);\r
                }\r
 \r
        }\r
index 7328e28..1b73018 100644 (file)
@@ -135,7 +135,7 @@ public class Joblist extends HttpServlet {
                } catch (SQLException e) {\r
                        e.printStackTrace();\r
                        throw new ServletException("SQLException : "\r
-                                       + e.getLocalizedMessage());\r
+                                       + e.getLocalizedMessage(), e);\r
                }\r
 \r
        }\r