sql-statement is logged even if excption is thrown
authorrk <rk>
Wed, 10 Oct 2001 09:38:24 +0000 (09:38 +0000)
committerrk <rk>
Wed, 10 Oct 2001 09:38:24 +0000 (09:38 +0000)
source/mir/storage/Database.java

index 973850a..ce5f4c5 100755 (executable)
@@ -869,14 +869,25 @@ public class Database implements StorageObject {
    * @param stmt Statemnt
    * @param sql Sql-String
    * @return ResultSet
-   * @exception StorageObjectException, SQLException
+   * @exception StorageObjectException
    */
-  public ResultSet executeSql (Statement stmt, String sql) throws StorageObjectException,
-      SQLException {
+  public ResultSet executeSql (Statement stmt, String sql)
+    throws StorageObjectException, SQLException
+  {
+    ResultSet rs;
     long startTime = (new java.util.Date()).getTime();
-    ResultSet rs = stmt.executeQuery(sql);
-    theLog.printInfo((new java.util.Date().getTime() - startTime) + "ms. for: "
+    try {
+      rs = stmt.executeQuery(sql);
+      theLog.printInfo((new java.util.Date().getTime() - startTime) + "ms. for: "
+        + sql);
+    }
+    catch (SQLException e)
+    {
+      theLog.printDebugInfo("Failed: " + (new java.util.Date().getTime() - startTime) + "ms. for: "
         + sql);
+      throw e;
+    }
+
     return  rs;
   }
 
@@ -889,6 +900,7 @@ public class Database implements StorageObject {
    */
   public ResultSet executeSql (PreparedStatement stmt) throws StorageObjectException,
       SQLException {
+
     long startTime = (new java.util.Date()).getTime();
     ResultSet rs = stmt.executeQuery();
     theLog.printInfo((new java.util.Date().getTime() - startTime) + "ms.");
@@ -928,10 +940,19 @@ public class Database implements StorageObject {
   public int executeUpdate(Statement stmt, String sql)
     throws StorageObjectException, SQLException
   {
+    int rs;
     long  startTime = (new java.util.Date()).getTime();
-    //theLog.printDebugInfo("trying: "+ sql);
-    int rs = stmt.executeUpdate(sql);
-    theLog.printInfo((new java.util.Date().getTime() - startTime) + "ms. for: " + sql);
+    try
+    {
+      rs = stmt.executeUpdate(sql);
+      theLog.printInfo((new java.util.Date().getTime() - startTime) + "ms. for: " + sql);
+    }
+    catch (SQLException e)
+    {
+      theLog.printDebugInfo("Failed: " + (new java.util.Date().getTime() - startTime) + "ms. for: "
+        + sql);
+      throw e;
+    }
     return rs;
   }