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 SequenceManagerNextValImpl.java
Date Fri, 19 Dec 2003 17:33:57 GMT
arminw      2003/12/19 09:33:57

  Modified:    src/java/org/apache/ojb/broker/util/sequence Tag:
                        OJB_BRANCH_1_0 SequenceManagerNextValImpl.java
  Log:
  fix bug in resource handling
  don't close any resources by your own, let
  StatementManager do that job
  (synchronize with changes made in trunk)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.10.2.1  +19 -26    db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerNextValImpl.java
  
  Index: SequenceManagerNextValImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerNextValImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.10.2.1
  diff -u -r1.10 -r1.10.2.1
  --- SequenceManagerNextValImpl.java	13 Aug 2003 18:16:10 -0000	1.10
  +++ SequenceManagerNextValImpl.java	19 Dec 2003 17:33:57 -0000	1.10.2.1
  @@ -54,17 +54,17 @@
    * <http://www.apache.org/>.
    */
   
  +import java.sql.ResultSet;
  +import java.sql.Statement;
  +
   import org.apache.commons.lang.SystemUtils;
   import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.broker.util.logging.Logger;
  -import org.apache.ojb.broker.util.logging.LoggerFactory;
  +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 java.sql.ResultSet;
  -import java.sql.SQLException;
  -import java.sql.Statement;
  +import org.apache.ojb.broker.util.logging.Logger;
  +import org.apache.ojb.broker.util.logging.LoggerFactory;
   
   /**
    * This SequenceManager implementation uses database
  @@ -188,7 +188,6 @@
                   throw new SequenceManagerException("Could not grab next id, sequence seems
to exist", e);
               }
           }
  -
           return result;
       }
   
  @@ -196,35 +195,29 @@
       {
           ResultSet rs = null;
           Statement stmt = null;
  -
  +        long result = -1;
  +        StatementManagerIF stmtMan = getBrokerForClass().serviceStatementManager();
           try
           {
  -            stmt = getBrokerForClass().serviceStatementManager().getGenericStatement(cld,
Query.NOT_SCROLLABLE);
  +            stmt = stmtMan.getGenericStatement(cld, Query.NOT_SCROLLABLE);
               rs = stmt.executeQuery(getPlatform().nextSequenceQuery(sequenceName));
               rs.next();
  -            return rs.getLong(1);
  +            result = rs.getLong(1);
           }
           finally
           {
  -            try
  -            {
  -                if (rs != null)
  -                    rs.close();
  -                if (stmt != null)
  -                    stmt.close();
  -            }
  -            catch (SQLException ignore)
  -            {
  -            }
  +            stmtMan.closeResources(stmt, rs);
           }
  +        return result;
       }
   
       protected void createSequence(ClassDescriptor cld, String sequenceName) throws Exception
       {
           Statement stmt = null;
  +        StatementManagerIF stmtMan = getBrokerForClass().serviceStatementManager();
           try
           {
  -            stmt = getBrokerForClass().serviceStatementManager().getGenericStatement(cld,
Query.NOT_SCROLLABLE);
  +            stmt = stmtMan.getGenericStatement(cld, Query.NOT_SCROLLABLE);
               stmt.execute(getPlatform().dropSequenceQuery(sequenceName));
           }
           catch (Exception ignore)
  @@ -234,9 +227,9 @@
           {
               try
               {
  -                if (stmt != null) stmt.close();
  +                stmtMan.closeResources(stmt, null);
               }
  -            catch (SQLException ignore)
  +            catch (Exception ignore)
               {
               }
           }
  @@ -250,9 +243,9 @@
           {
               try
               {
  -                if (stmt != null) stmt.close();
  +                getBrokerForClass().serviceStatementManager().closeResources(stmt, null);
               }
  -            catch (SQLException ignore)
  +            catch (Exception ignore)
               {
               }
           }
  
  
  

---------------------------------------------------------------------
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