[jboss-svn-commits] JBL Code SVN: r5825 - labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Aug 12 11:08:57 EDT 2006


Author: tfennelly
Date: 2006-08-12 11:08:54 -0400 (Sat, 12 Aug 2006)
New Revision: 5825

Modified:
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DbUtils.java
Log:
Fixed the connection commit bug - was OK on Postgres, but  MySQL appeared to have an issue with it.  Had a commit call on the connection even though JDBC Connections have autocommit on by default - code I forgot to remove when I ditched using the Connection Pooling code.

Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DbUtils.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DbUtils.java	2006-08-12 14:32:58 UTC (rev 5824)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/util/DbUtils.java	2006-08-12 15:08:54 UTC (rev 5825)
@@ -204,10 +204,12 @@
 		}
 		public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 			if(method.getName().equals("close")) {
-				// Caught the call to close the resultset - close the associated DbResources too!
-				Object returnObj = method.invoke(resultSet, args);
-				dbResources.close();
-				return returnObj;
+				try {
+					// Caught the call to close the resultset - close the associated DbResources too!
+					return method.invoke(resultSet, args);
+				} finally {
+					dbResources.close();
+				}
 			} else {
 				return method.invoke(resultSet, args);
 			}
@@ -228,7 +230,9 @@
 			try {
 				// Register the driver..
 				Class.forName(dbDriver).newInstance();
+				// Create the connection...
 				con = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
+				// Create a regular statement for execution...
 				stat = con.createStatement();
 			} catch (Exception e) {
 				TestCaseUtils.logAndFail("Failed to connect to database.  Connection Properties: " + properties, logger, e);
@@ -237,21 +241,14 @@
 		
 		private void close() {
 			try {
-				// Commit on the connection!.
-				con.commit();
-			} catch (SQLException e) {
-				TestCaseUtils.logAndFail("Failed to commit to database: " + properties, logger, e);
-			} finally {
-				try {
-					if (stat != null) {
-						stat.close();
-					}
-					if (con != null) {
-						con.close();
-					}
-				} catch (SQLException e) {
-					TestCaseUtils.logAndFail("Failed to close database resources.  Connection Properties: " + properties, logger, e);
+				if (stat != null) {
+					stat.close();
 				}
+				if (con != null) {
+					con.close();
+				}
+			} catch (SQLException e) {
+				TestCaseUtils.logAndFail("Failed to close database resources.  Connection Properties: " + properties, logger, e);
 			}
 		}
 	}




More information about the jboss-svn-commits mailing list