User: dsundstrom
  Date: 02/04/12 13:47:10

  Modified:    src/main/org/jboss/ejb/plugins/cmp/jdbc
                        JDBCStartCommand.java JDBCStopCommand.java
  Log:
  Forgot to add new transaction handling code to stop.
  
  Revision  Changes    Path
  1.26      +1 -4      
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- JDBCStartCommand.java     12 Apr 2002 18:09:07 -0000      1.25
  +++ JDBCStartCommand.java     12 Apr 2002 20:47:09 -0000      1.26
  @@ -43,7 +43,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.25 $
  + * @version $Revision: 1.26 $
    */
   public class JDBCStartCommand {
   
  @@ -159,10 +159,7 @@
            Connection con = null;
            Statement statement = null;
            try {        
  -            // get the connection
               con = dataSource.getConnection();
  -
  -            // create the statement
               statement = con.createStatement();
            
               // execute sql
  
  
  
  1.14      +42 -19    
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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JDBCStopCommand.java      12 Apr 2002 20:00:46 -0000      1.13
  +++ JDBCStopCommand.java      12 Apr 2002 20:47:09 -0000      1.14
  @@ -15,6 +15,9 @@
   import java.util.Iterator;
   import java.util.List;
   import javax.sql.DataSource;
  +import javax.transaction.Status;
  +import javax.transaction.Transaction;
  +import javax.transaction.TransactionManager;
   
   import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge;
   import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge;
  @@ -29,7 +32,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.13 $
  + * @version $Revision: 1.14 $
    */
   public class JDBCStopCommand {
   
  @@ -98,21 +101,24 @@
         }
   
         // since we use the pools, we have to do this within a transaction
  -      try 
  -      {
  -         manager.getContainer().getTransactionManager().begin ();         
  +
  +      // suspend the current transaction
  +      TransactionManager tm = manager.getContainer().getTransactionManager();
  +      Transaction oldTransaction = null;
  +      try {
  +         oldTransaction = tm.suspend();
  +      } catch(Exception e) {
  +         log.error("Could not suspend current transaction before drop table. " +
  +               "'" + tableName + "' will not be dropped.", e);
         }
  -      catch (Exception e)
  -      {
  -         log.error("Could not get transaction to drop table in", e);
  -         return;
  -      } // end of try-catch
  +
         try {
  -         // get the connection
  -         con = dataSource.getConnection();
  +         // start the new transaction
  +         tm.begin();
  +
            Statement statement = null;
  -         try {        
  -            // create the statement
  +         try {
  +            con = dataSource.getConnection();
               statement = con.createStatement();
            
               // execute sql
  @@ -124,16 +130,33 @@
            {
               JDBCUtil.safeClose(statement);
               JDBCUtil.safeClose(con);
  -         } // end of finally
  -         manager.getContainer().getTransactionManager().commit ();
  -      } 
  -      catch(Exception e) 
  -      {
  +         }
  +
  +         // commit the new transaction
  +         tm.commit();
  +      } catch(Exception e) {
            log.debug("Could not drop table " + tableName);
  +
  +         // try to rollback the new transaction
            try {
  -            manager.getContainer().getTransactionManager().rollback ();
  +            if(tm.getStatus() != Status.STATUS_NO_TRANSACTION) {
  +               tm.rollback();
  +            }
            } catch(Exception _e) {
               log.error("Could not roll back transaction: ", e);
  +         }
  +      } finally {
  +         try {
  +            // suspend the new transaction
  +            tm.suspend();
  +
  +            // resume the old transaction
  +            if(oldTransaction != null) {
  +               tm.resume(oldTransaction);
  +            }
  +         } catch(Exception e) {
  +            log.error("Could not reattach original transaction after " +
  +                  "drop table");
            }
         }
      }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to