db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BoonThai Hoh <...@swiftinnovation.com>
Subject safeRollback problem
Date Tue, 22 Jul 2003 21:28:24 GMT
Hi,

I am looking at Transaction.safeRollback in 3.0 and 3.0.2 and am running 
into errors that did not exist in the alpha build.

However, it simply calls Transaction.rollback(con) which can throws 
NullPointerException if con is null. This breaks alot of my code since I 
use safeRollback extensively for precautionary measure. Furthermore, the 
signature for rollback declare that TorqueException will be thrown and does 
not specify NullPointerException.

Is this a bug? or is there logic to this?

Thanks,

BT

     public static void rollback(Connection con) throws TorqueException
     {
         if (con == null)
         {
             throw new NullPointerException(
                 "Connection object was null. "
                     + "This could be due to a misconfiguration of the "
                     + "DataSourceFactory. Check the logs and 
Torque.properties "
                     + "to better determine the cause.");
         }

         try
         {
             if (con.getMetaData().supportsTransactions()
                 && con.getAutoCommit() == false)
             {
                 con.rollback();
                 con.setAutoCommit(true);
             }
         }
         catch (SQLException e)
         {
             category.error(
                 "An attempt was made to rollback a transaction "
                     + "but the database did not allow the operation to be "
                     + "rolled back.",
                 e);

             throw new TorqueException(e);
         }
         finally
         {
             Torque.closeConnection(con);
         }
     }

     public static void safeRollback(Connection con)
     {
         try
         {
             Transaction.rollback(con);
         }
         catch (TorqueException e)
         {
             category.error("An error occured during rollback.", e);
         }
     }


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


Mime
View raw message