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:51:27 GMT
arminw      2005/10/09 09:51:26

  Modified:    src/java/org/apache/ojb/broker/util/sequence Tag:
                        OJB_1_0_RELEASE SequenceManagerHelper.java
  Log:
  use StatementManager to close used resources
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.17.2.7  +13 -13    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.17.2.6
  retrieving revision 1.17.2.7
  diff -u -r1.17.2.6 -r1.17.2.7
  --- SequenceManagerHelper.java	5 Sep 2005 23:42:56 -0000	1.17.2.6
  +++ SequenceManagerHelper.java	9 Oct 2005 16:51:26 -0000	1.17.2.7
  @@ -15,22 +15,22 @@
    * limitations under the License.
    */
   
  +import java.sql.ResultSet;
  +import java.sql.Statement;
  +import java.util.Collection;
  +import java.util.Iterator;
  +import java.util.Properties;
  +import java.util.Vector;
  +
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerException;
  +import org.apache.ojb.broker.accesslayer.StatementManagerIF;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   
  -import java.sql.ResultSet;
  -import java.sql.SQLException;
  -import java.sql.Statement;
  -import java.util.Collection;
  -import java.util.Iterator;
  -import java.util.Vector;
  -import java.util.Properties;
  -
   /**
    * Helper class for SequenceManager implementations.
    *
  @@ -337,13 +337,14 @@
           long result = 0;
           ResultSet rs = null;
           Statement stmt = null;
  +        StatementManagerIF sm = brokerForClass.serviceStatementManager();
           String table = cldForOriginalOrExtent.getFullTableName();
           // String column = cld.getFieldDescriptorByName(fieldName).getColumnName();
           String sql = SM_SELECT_MAX + column + SM_FROM + table;
           try
           {
               //lookup max id for the current class
  -            stmt = brokerForClass.serviceStatementManager().getGenericStatement(cldForOriginalOrExtent,
Query.NOT_SCROLLABLE);
  +            stmt = sm.getGenericStatement(cldForOriginalOrExtent, Query.NOT_SCROLLABLE);
               rs = stmt.executeQuery(sql);
               rs.next();
               result = rs.getLong(1);
  @@ -358,10 +359,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