User: d_jencks
Date: 02/02/07 19:51:09
Modified: src/main/org/jboss/ejb/plugins/cmp/jdbc
JDBCStartCommand.java JDBCStopCommand.java
Log:
closed connections before end of transaction. Problem showed up using an xa connector
Revision Changes Path
1.19 +26 -16
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
Index: JDBCStartCommand.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- JDBCStartCommand.java 5 Feb 2002 20:31:23 -0000 1.18
+++ JDBCStartCommand.java 8 Feb 2002 03:51:09 -0000 1.19
@@ -40,7 +40,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Joe Shevland</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Michel de Groot</a>
- * @version $Revision: 1.18 $
+ * @version $Revision: 1.19 $
*/
public class JDBCStartCommand {
@@ -136,23 +136,37 @@
Connection con = null;
Statement statement = null;
- try {
- // since we use the pools, we have to do this within a transaction
- manager.getContainer().getTransactionManager().begin ();
+ // since we use the pools, we have to do this within a transaction
+ try
+ {
+ manager.getContainer().getTransactionManager().begin ();
+ }
+ catch (Exception e)
+ {
+ log.error("Could not get transaction to create table in", e);
+ throw new DeploymentException("Could not get transaction to create table
in", e);
+ } // end of try-catch
+ try {
// get the connection
con = dataSource.getConnection();
-
- // create the statement
- statement = con.createStatement();
+ try {
+ // create the statement
+ statement = con.createStatement();
// execute sql
- log.debug("Executing SQL: " + sql);
- statement.executeUpdate(sql);
-
- // commit the transaction
+ log.debug("Executing SQL: " + sql);
+ statement.executeUpdate(sql);
+ }
+ finally
+ {
+ JDBCUtil.safeClose(statement);
+ JDBCUtil.safeClose(con);
+ } // end of finally
manager.getContainer().getTransactionManager().commit ();
- } catch(Exception e) {
+ }
+ catch(Exception e)
+ {
log.debug("Could not create table " + tableName);
try {
manager.getContainer().getTransactionManager().rollback ();
@@ -160,11 +174,7 @@
log.error("Could not roll back transaction: ", e);
}
throw new DeploymentException("Error while creating table", e);
- } finally {
- JDBCUtil.safeClose(statement);
- JDBCUtil.safeClose(con);
}
-
// success
log.info("Created table '" + tableName + "' successfully.");
Set createdTables = (Set)manager.getApplicationData(CREATED_TABLES_KEY);
1.10 +30 -23
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
Index: JDBCStopCommand.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JDBCStopCommand.java 15 Jan 2002 22:26:41 -0000 1.9
+++ JDBCStopCommand.java 8 Feb 2002 03:51:09 -0000 1.10
@@ -29,7 +29,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class JDBCStopCommand {
@@ -97,35 +97,42 @@
JDBCUtil.safeClose(con);
}
- Statement statement = null;
+ // since we use the pools, we have to do this within a transaction
+ try
+ {
+ manager.getContainer().getTransactionManager().begin ();
+ }
+ catch (Exception e)
+ {
+ log.error("Could not get transaction to drop table in", e);
+ return;
+ } // end of try-catch
try {
- // since we use the pools, we have to do this within a transaction
- manager.getContainer().getTransactionManager().begin();
-
// get the connection
con = dataSource.getConnection();
+ Statement statement = null;
+ try {
+ // create the statement
+ statement = con.createStatement();
- // create the statement
- statement = con.createStatement();
-
- // execute sql
- statement.executeUpdate("DROP TABLE " + tableName);
-
- // commit the transaction
- manager.getContainer().getTransactionManager().commit();
-
- // success
- log.info("Dropped table '" + tableName + "' successfully.");
- } catch (Exception e) {
- log.debug("Could not drop table " + tableName + ": " + e.getMessage());
+ // execute sql
+ statement.executeUpdate("DROP TABLE " + tableName);
+ }
+ finally
+ {
+ JDBCUtil.safeClose(statement);
+ JDBCUtil.safeClose(con);
+ } // end of finally
+ manager.getContainer().getTransactionManager().commit ();
+ }
+ catch(Exception e)
+ {
+ log.debug("Could not drop table " + tableName);
try {
manager.getContainer().getTransactionManager().rollback ();
- } catch (Exception _e) {
- log.error("Could not roll back transaction: "+ _e.getMessage());
+ } catch(Exception _e) {
+ log.error("Could not roll back transaction: ", e);
}
- } finally {
- JDBCUtil.safeClose(statement);
- JDBCUtil.safeClose(con);
}
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development