You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Thomas Franke <fr...@softenergy.de> on 2005/11/09 14:09:47 UTC

PlatformInformixImpl

Hello Armin,

I implemented the prepareNextValProcedureStatement() method in the class above.
Now the SequenceManagerStoredProcedureImpl works also together with Informix.
This implementation is tested against Informix Dynamik Server 9.4 and the
Informix JDBC.3.00.JC1 driver.

I attached also the sql statements to create the spl function and the OJB
sequence table.

Maybe you can use it.

Best Regards,

Thomas

Re: PlatformInformixImpl

Posted by Thomas Franke <fr...@softenergy.de>.
Hi Armin,

> Would it be possible to use INTEGER in Informix too? Ask this because I want
> to move #prepareNextValProcedureStatement implementation method to
> PlatformDefaultImpl.

I could do that but I'll explain you why I did this decision.
First of all the SequenceManagerStoredProcedureImpl#buildNextSequence method is
used the method CallableStatement#getLong to get the result. Thus with
BigInteger it passes Long values too.
Secondly the necessary argument of the method CallableStatement#prepareCall for
informix is a little bit different as the implemention of oracle or mssql.

Have a look at the difference:

This is the String argument for oracle and mssql:

"{? = call " + procedureName + "(?)}"

and this one is the String argument for informix:

"{? = call " + procedureName + "(?,?)}"

As you can see the informix implementation needs two '?' arguments. And this is
necessary for the database and driver type. The first '?' argument is necessary
to define the out parameter to get the result over the CallableStatement#getLong.
Because of a bug in the informix driver you have also to call
CallableStatement#executeQuery here. It seems that the
CallableStatement#executeUpdate is incorrectly implemented.

So if you implement the PlatformDefaultImpl#prepareNextValProcedureStatement you
have continue to implement the
PlatformInformixImpl#prepareNextValProcedureStatement.

Regards,

Thomas

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


Re: PlatformInformixImpl

Posted by Armin Waibel <ar...@apache.org>.
Hi Thomas,

in PlatformInformixImpl#prepareNextValProcedureStatement the 
registerOutParameter(...) call use type Types.BIGINT. In 
PlatformMsSQLImpl Types.INTEGER is used.
Would it be possible to use INTEGER in Informix too? Ask this because I 
want to move #prepareNextValProcedureStatement implementation method to 
PlatformDefaultImpl.

regards,
Armin

Thomas Franke wrote:
> Hello Armin,
> 
> I implemented the prepareNextValProcedureStatement() method in the class above.
> Now the SequenceManagerStoredProcedureImpl works also together with Informix.
> This implementation is tested against Informix Dynamik Server 9.4 and the
> Informix JDBC.3.00.JC1 driver.
> 
> I attached also the sql statements to create the spl function and the OJB
> sequence table.
> 
> Maybe you can use it.
> 
> Best Regards,
> 
> Thomas
> 
> 
> ------------------------------------------------------------------------
> 
> drop table ojb_nextval_seq;
> create table ojb_nextval_seq
> (
>     seq_name    varchar(250,0) not null,
>     max_key     int8,
>     primary key(seq_name)
> );
> 
> 
> drop function ojb_nextval_proc;
> create function ojb_nextval_proc(out arg1 int8, arg2 varchar(250,250))
> returns int8;
> let arg1 = 0;
> update ojb_nextval_seq set max_key = max_key + 1 where seq_name = arg2;
> select max_key into arg1 from ojb_nextval_seq where seq_name = arg2;
> return arg1;
> end function;
> 
> 
> ------------------------------------------------------------------------
> 
> package org.apache.ojb.broker.platforms;
> 
> /* Copyright 2002-2004 The Apache Software Foundation
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  *
>  *     http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
> import java.sql.CallableStatement;
> import java.sql.Connection;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> import java.sql.Types;
> 
> /**
>  * This class extends <code>PlatformDefaultImpl</code> and defines specific
>  * behavior for the Informix platform.
>  * 
>  * @version 1.0
>  * @author Thomas Mahler
>  */
> public class PlatformInformixImpl extends PlatformDefaultImpl {
>     /**
>      * @see Platform#initializeJdbcConnection
>      */
>     public void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
>             Connection conn) throws PlatformException {
>         super.initializeJdbcConnection(jcd, conn);
>         try {
>             Statement stmt = conn.createStatement();
>             stmt.execute("SET LOCK MODE TO WAIT");
>         } 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);
>         }
>     }
> }
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org

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


Re: PlatformInformixImpl

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Dudziak wrote:

> but this seems to be down at the moment. But I guess it will be online
> again in a couple of hours.
Thanks, I'll try it.

Regards,

Thomas

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


Re: PlatformInformixImpl

Posted by Thomas Dudziak <to...@gmail.com>.
On 11/9/05, Thomas Franke <fr...@softenergy.de> wrote:

> Yes, I will both of them.
> But I could need a little help. Where can I do the first one?

Usually you would do so here:

http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10700

but this seems to be down at the moment. But I guess it will be online
again in a couple of hours.

Tom

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


Re: PlatformInformixImpl

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Dudziak wrote:

> Thanks!
> Could you perhaps create a feature request in JIRA and attach the source there ?
> Would you be willing to run the unit tests when we cut new releases ?
Yes, I will both of them.
But I could need a little help. Where can I do the first one?

Regards,

Thomas

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


Re: PlatformInformixImpl

Posted by Thomas Dudziak <to...@gmail.com>.
On 11/9/05, Thomas Franke <fr...@softenergy.de> wrote:

> I implemented the prepareNextValProcedureStatement() method in the class above.
> Now the SequenceManagerStoredProcedureImpl works also together with Informix.
> This implementation is tested against Informix Dynamik Server 9.4 and the
> Informix JDBC.3.00.JC1 driver.
>
> I attached also the sql statements to create the spl function and the OJB
> sequence table.
>
> Maybe you can use it.

Thanks!
Could you perhaps create a feature request in JIRA and attach the source there ?
Would you be willing to run the unit tests when we cut new releases ?

Tom

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