From: rk Date: Wed, 10 Oct 2001 09:38:24 +0000 (+0000) Subject: sql-statement is logged even if excption is thrown X-Git-Tag: prexmlproducerconfig~353 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=0d6c9bade5c8eb9958c2f007655df7162165115c;p=mir.git sql-statement is logged even if excption is thrown --- diff --git a/source/mir/storage/Database.java b/source/mir/storage/Database.java index 973850ae..ce5f4c59 100755 --- a/source/mir/storage/Database.java +++ b/source/mir/storage/Database.java @@ -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; }