arminw      2005/11/09 17:03:51

  Modified:    src/java/org/apache/ojb/broker/platforms Tag:
                        OJB_1_0_RELEASE PlatformInformixImpl.java
               src/java/org/apache/ojb/broker/util/sequence Tag:
                        OJB_1_0_RELEASE
                        SequenceManagerStoredProcedureImpl.java
  Log:
  improvement by Thomas Franke: support of SequenceManagerStoredProcedureImpl 
for Informix DB
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.9.2.1   +36 -8     
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.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- PlatformInformixImpl.java 22 May 2004 09:55:33 -0000      1.9
  +++ PlatformInformixImpl.java 10 Nov 2005 01:03:51 -0000      1.9.2.1
  @@ -15,24 +15,25 @@
    * limitations under the License.
    */
   
  -import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  -
  +import java.sql.CallableStatement;
   import java.sql.Connection;
   import java.sql.SQLException;
   import java.sql.Statement;
  +import java.sql.Types;
  +
  +import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
   
   /**
    * This class extends <code>PlatformDefaultImpl</code> and defines specific
    * behavior for the Informix platform.
  - * @version  1.0
  - * @author           Thomas Mahler
  + *
  + * @version 1.0
  + * @author Thomas Mahler
    */
   public class PlatformInformixImpl extends PlatformDefaultImpl
   {
   
  -    /**
  -     * @see Platform#initializeJdbcConnection
  -     */
  +    /** @see Platform#initializeJdbcConnection */
       public void initializeJdbcConnection(JdbcConnectionDescriptor jcd, 
Connection conn) throws PlatformException
       {
           super.initializeJdbcConnection(jcd, conn);
  @@ -41,10 +42,37 @@
               Statement stmt = conn.createStatement();
               stmt.execute("SET LOCK MODE TO WAIT");
           }
  -        catch (SQLException e)
  +        catch(SQLException e)
           {
               // ignore it
           }
       }
   
  +    /**
  +     * @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                   revision
  No                   revision
  1.11.2.1  +4 -7      
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.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- SequenceManagerStoredProcedureImpl.java   25 May 2004 11:21:02 -0000      
1.11
  +++ SequenceManagerStoredProcedureImpl.java   10 Nov 2005 01:03:51 -0000      
1.11.2.1
  @@ -143,20 +143,17 @@
        * Insert syntax for our special table
        * @param sequenceName
        * @param maxKey
  -     * @return
  +     * @return sequence insert statement
        */
       protected String sp_createSequenceQuery(String sequenceName, long maxKey)
       {
  -        String result = "insert into " + SEQ_TABLE_NAME + " ("
  +        return "insert into " + SEQ_TABLE_NAME + " ("
                   + SEQ_NAME_STRING + "," + SEQ_ID_STRING +
                   ") values ('" + sequenceName + "'," + maxKey + ")";
  -        return result;
       }
   
       /**
  -     * 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to