synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r603982 - /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/DBReportMediator.java
Date Thu, 13 Dec 2007 19:00:28 GMT
Author: asankha
Date: Thu Dec 13 11:00:28 2007
New Revision: 603982

URL: http://svn.apache.org/viewvc?rev=603982&view=rev
Log:
close DB connections cleanly

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/DBReportMediator.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/DBReportMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/DBReportMediator.java?rev=603982&r1=603981&r2=603982&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/DBReportMediator.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/DBReportMediator.java
Thu Dec 13 11:00:28 2007
@@ -23,6 +23,7 @@
 
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.sql.Connection;
 
 /**
  * A mediator that writes (i.e. inserts one row) to a table using message information
@@ -34,8 +35,10 @@
         boolean traceOn = isTraceOn(msgCtx);
         boolean traceOrDebugOn = isTraceOrDebugOn(traceOn);
 
+        Connection con = null;
         try {
             PreparedStatement ps = getPreparedStatement(stmnt, msgCtx);
+            con = ps.getConnection();
             int count = ps.executeUpdate();
 
             if (count > 0) {
@@ -49,9 +52,17 @@
                         "No rows were inserted for statement : " + stmnt.getRawStatement());
                 }
             }
+            con.commit();
+
         } catch (SQLException e) {
             handleException("Error execuring insert statement : " + stmnt.getRawStatement()
+
                 " against DataSource : " + getDSName(), e, msgCtx);
+        } finally {
+            if (con != null) {
+                try {
+                    con.close();
+                } catch (SQLException ignore) {}
+            }
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org


Mime
View raw message