Print

Print


Author: [log in to unmask]
Date: Mon Feb  8 15:18:07 2016
New Revision: 4189

Log:
Have an ACTUAL check if the database is still sane.

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	Mon Feb  8 15:18:07 2016
@@ -750,6 +750,23 @@
     }
 
     /**
+     * Don't just return a stored parameter. ACTUALLY check whether you are still connected to the $@#$%! database.
+     *
+     * @return <code>true</code> if connected
+     */    
+    public boolean checkIfConnected(){
+        try {
+            this.connection.createStatement().execute("SELECT * from svt_channels limit 1;");
+        } catch (final SQLException x) {
+            LOGGER.info("====== Checking database found it not connected. ");
+            this.isConnected = false;
+            return false;
+        }
+        LOGGER.info("====== Checking database found and found it still connected. ");
+        return true;
+    }
+    
+    /**
      * True if conditions system is frozen
      *
      * @return <code>true</code> if conditions system is currently frozen