db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/util/sequence SequenceManagerHelper.java
Date Sun, 09 Oct 2005 16:54:13 GMT
arminw      2005/10/09 09:54:13

  Modified:    src/java/org/apache/ojb/broker/util/sequence
                        SequenceManagerHelper.java
  Log:
  use StatementManager to close resources
  
  Revision  Changes    Path
  1.24      +9 -11     db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java
  
  Index: SequenceManagerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- SequenceManagerHelper.java	3 Sep 2005 18:14:06 -0000	1.23
  +++ SequenceManagerHelper.java	9 Oct 2005 16:54:13 -0000	1.24
  @@ -16,7 +16,6 @@
    */
   
   import java.sql.ResultSet;
  -import java.sql.SQLException;
   import java.sql.Statement;
   import java.util.Collection;
   import java.util.Iterator;
  @@ -25,6 +24,7 @@
   
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerException;
  +import org.apache.ojb.broker.accesslayer.StatementManager;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
   import org.apache.ojb.broker.platforms.Platform;
  @@ -316,9 +316,7 @@
               PersistenceBroker brokerForClass, ClassDescriptor cldForOriginalOrExtent, FieldDescriptor
original)
               throws PersistenceBrokerException
       {
  -        Platform platform = brokerForClass.serviceConnectionManager().getSupportedPlatform();
           FieldDescriptor field = null;
  -
           if (!original.getClassDescriptor().equals(cldForOriginalOrExtent))
           {
               // check if extent match not the same table
  @@ -339,17 +337,18 @@
               return 0;
           }
   
  +        Platform platform = brokerForClass.serviceConnectionManager().getSupportedPlatform();
  +        StatementManager sm = brokerForClass.serviceStatementManager();
           String column = platform.quoteName(field.getColumnName());
  +        String table = platform.quoteName(cldForOriginalOrExtent.getFullTableName());
  +        String sql = SM_SELECT_MAX + column + SM_FROM + table;
           long result = 0;
           ResultSet rs = null;
           Statement stmt = null;
  -        String table = platform.quoteName(cldForOriginalOrExtent.getFullTableName());
  -        String sql = SM_SELECT_MAX + column + SM_FROM + table;
  -
           try
           {
               //lookup max id for the current class
  -            stmt = brokerForClass.serviceStatementManager().getGenericStatement(Query.NOT_SCROLLABLE);
  +            stmt = sm.getGenericStatement(Query.NOT_SCROLLABLE);
               rs = stmt.executeQuery(sql);
               rs.next();
               result = rs.getLong(1);
  @@ -364,10 +363,9 @@
           {
               try
               {
  -                if (rs != null) rs.close();
  -                if (stmt != null) stmt.close();
  +                sm.closeResources(stmt, rs);
               }
  -            catch (SQLException ignore)
  +            catch (Exception ignore)
               {
                   // ignore it
              }
  
  
  

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


Mime
View raw message