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 SequenceManagerStoredProcedureImpl.java
Date Thu, 10 Nov 2005 01:17:24 GMT
arminw      2005/11/09 17:17:24

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformInformixImpl.java
               src/java/org/apache/ojb/broker/util/sequence
                        SequenceManagerStoredProcedureImpl.java
  Log:
  improvement by Thomas Franke: support of SequenceManagerStoredProcedureImpl for Informix
DB
  
  Revision  Changes    Path
  1.11      +45 -2     db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformInformixImpl.java
  
  Index: PlatformInformixImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformInformixImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PlatformInformixImpl.java	15 Sep 2004 18:43:13 -0000	1.10
  +++ PlatformInformixImpl.java	10 Nov 2005 01:17:23 -0000	1.11
  @@ -20,6 +20,8 @@
   import java.sql.Connection;
   import java.sql.SQLException;
   import java.sql.Statement;
  +import java.sql.CallableStatement;
  +import java.sql.Types;
   
   /**
    * This class extends <code>PlatformDefaultImpl</code> and defines specific
  @@ -36,16 +38,57 @@
       public void initializeJdbcConnection(JdbcConnectionDescriptor jcd, Connection conn)
throws PlatformException
       {
           super.initializeJdbcConnection(jcd, conn);
  +        Statement stmt = null;
           try
           {
  -            Statement stmt = conn.createStatement();
  +            stmt = conn.createStatement();
               stmt.execute("SET LOCK MODE TO WAIT");
  -            stmt.close();
           }
           catch (SQLException e)
           {
               // ignore it
           }
  +        finally
  +        {
  +            if(stmt != null)
  +            {
  +                try
  +                {
  +                    stmt.close();
  +                }
  +                catch(SQLException e)
  +                {
  +                    // ignore
  +                }
  +            }
  +        }
       }
   
  +    /**
  +     * @see org.apache.ojb.broker.platforms.PlatformDefaultImpl#prepareNextValProcedureStatement(java.sql.Connection,
  +     *      java.lang.String, java.lang.String)
  +     */
  +    public CallableStatement prepareNextValProcedureStatement(Connection con, String procedureName,
  +                                                              String sequenceName) throws
PlatformException
  +    {
  +        try
  +        {
  +            /*
  +             * Following works for Informix Dynamik Server 9.4 and the Informix
  +             * JDBC.3.00.JC1 driver. It is important to call the executeQuery()
  +             * method here because the executeUpdate() method doesn't work
  +             * correctly and returns an error if it is called alone.
  +             */
  +            String sp = "{? = call " + procedureName + "(?,?)}";
  +            CallableStatement cs = con.prepareCall(sp);
  +            cs.registerOutParameter(1, Types.BIGINT);
  +            cs.setString(2, sequenceName);
  +            cs.executeQuery();
  +            return cs;
   }
  +        catch(SQLException e)
  +        {
  +            throw new PlatformException(e);
  +        }
  +    }
  +}
  \ No newline at end of file
  
  
  
  1.15      +2 -4      db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java
  
  Index: SequenceManagerStoredProcedureImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerStoredProcedureImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SequenceManagerStoredProcedureImpl.java	27 Aug 2005 12:23:16 -0000	1.14
  +++ SequenceManagerStoredProcedureImpl.java	10 Nov 2005 01:17:24 -0000	1.15
  @@ -154,9 +154,7 @@
       }
   
       /**
  -     * Gets the actual key
  -     *
  -     * Will create a new row with the max key of table if it
  +     * Gets the actual key - will create a new row with the max key of table if it
        * does not exist.
        * @param field
        * @return
  
  
  

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