[jboss-cvs] JBoss Messaging SVN: r2296 - in trunk: tests/src/org/jboss/test/messaging/tools/jmx and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 13 09:23:35 EST 2007
Author: timfox
Date: 2007-02-13 09:23:35 -0500 (Tue, 13 Feb 2007)
New Revision: 2296
Modified:
trunk/src/main/org/jboss/messaging/core/plugin/JDBCSupport.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
Log:
More stuff to allow ddl statements to execute in own tx
Modified: trunk/src/main/org/jboss/messaging/core/plugin/JDBCSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/JDBCSupport.java 2007-02-13 13:49:16 UTC (rev 2295)
+++ trunk/src/main/org/jboss/messaging/core/plugin/JDBCSupport.java 2007-02-13 14:23:35 UTC (rev 2296)
@@ -200,9 +200,6 @@
private void createSchema() throws Exception
{
- Connection conn = null;
- TransactionWrapper tx = new TransactionWrapper();
-
// Postgresql will not process any further commands in a transaction
// after a create table fails:
// org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
@@ -212,8 +209,12 @@
while (iter.hasNext())
{
+ Connection conn = null;
+
+ TransactionWrapper tx = new TransactionWrapper();
+
try
- {
+ {
conn = ds.getConnection();
String statementName = (String)iter.next();
@@ -231,6 +232,8 @@
catch (SQLException e)
{
log.debug("Failed to execute: " + statement, e);
+
+ tx.exceptionOccurred();
}
}
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2007-02-13 13:49:16 UTC (rev 2295)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2007-02-13 14:23:35 UTC (rev 2296)
@@ -1454,144 +1454,82 @@
}
ic.close();
}
+
+ private void executeStatement(TransactionManager mgr, DataSource ds, String statement) throws Exception
+ {
+ Connection conn = null;
+ boolean exception = false;
+
+ try
+ {
+ try
+ {
+ mgr.begin();
+
+ conn = ds.getConnection();
+
+ PreparedStatement ps = conn.prepareStatement(statement);
+
+ ps.executeUpdate();
+
+ log.debug(statement + ": dropped ");
+
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ //Ignore
+ exception = true;
+ }
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+
+ if (exception)
+ {
+ mgr.rollback();
+ }
+ else
+ {
+ mgr.commit();
+ }
+ }
+
+
+ }
protected void dropAllTables() throws Exception
{
log.info("DROPPING ALL TABLES FROM DATABASE!");
InitialContext ctx = new InitialContext();
+
+ //We need to execute each drop in its own transaction otherwise postgresql will
+ //not execute further commands after one fails
TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
javax.transaction.Transaction txOld = mgr.suspend();
- mgr.begin();
+
+ executeStatement(mgr, ds, "JBM_POSTOFFICE");
+
+ executeStatement(mgr, ds, "JBM_MSG_REF");
- Connection conn = ds.getConnection();
+ executeStatement(mgr, ds, "JBM_MSG");
+
+ executeStatement(mgr, ds, "JBM_TX");
- String sql = null;
+ executeStatement(mgr, ds, "JBM_COUNTER");
- PreparedStatement ps = null;
-
- try
- {
- sql = "DROP TABLE JBM_POSTOFFICE";
-
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_POSTOFFICE: dropped ");
-
- ps.close();
- }
- catch (SQLException e)
- {
- //Ignore
- }
-
- try
- {
- sql = "DROP TABLE JBM_MSG_REF";
-
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_MSG_REF: dropped ");
-
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- }
-
- try
- {
- sql = "DROP TABLE JBM_MSG";
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_MSG: dropped ");
-
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- }
-
- try
- {
- sql = "DROP TABLE JBM_TX";
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_TX: dropped ");
-
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- }
-
- try
- {
- sql = "DROP TABLE JBM_COUNTER";
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_COUNTER: dropped ");
-
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- }
-
- try
- {
- sql = "DROP TABLE JBM_USER";
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_USER: dropped ");
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- }
+ executeStatement(mgr, ds, "JBM_USER");
- try
- {
- sql = "DROP TABLE JBM_ROLE";
- ps = conn.prepareStatement(sql);
-
- ps.executeUpdate();
-
- log.debug("JBM_ROLE: dropped ");
-
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- }
+ executeStatement(mgr, ds, "JBM_ROLE");
- conn.close();
-
- mgr.commit();
-
- log.debug("committed");
-
if (txOld != null)
{
mgr.resume(txOld);
More information about the jboss-cvs-commits
mailing list