commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: DBCP and informix issues!
Date Wed, 19 Aug 2009 11:34:27 GMT
Ok, first question, why are you needing to use the informix-specific
API?  Secondly, did you configure your data source to allow access to
the underlying connection (there's a property that controls that).

On Wed, Aug 19, 2009 at 1:32 AM, Gerardo Velez<jgerardo.velez@gmail.com> wrote:
> Hi James!
>
> Thank you for response!
>
> Unfortunatelly, I had problems trying to use the Delegating Connection, here
> is my snippet of code and the error arised.
>
> [Code1]
> import org.apache.commons.dbcp.DelegatingConnection;
>
> java.sql.Connection conn =
> (DelegatingConnection)dataSource.getConnection()).getInnermostDelegate();
>
> java.sql.Statement  stmt = conn.createStatement();
>
> [Error 1]
>
> java.lang.ClassCastException:
> org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
> cannot be cast to org.apache.commons.dbcp.DelegatingConnection
>
>
> As I'm using tomcat 6.0.20 as a web server, I already read that tomcat
> renamed dbcp library to tomcat-dbcp.jar in order to no make an interference
> with another application, so actually I've tried this
>
> [Code2]
> import org.apache.tomcat.dbcp.DelegatingConnection;
>
> java.sql.Connection conn =
> (DelegatingConnection)dataSource.getConnection()).getInnermostDelegate();
>
> java.sql.Statement  stmt = conn.createStatement();
>
> [Error 2]
>
> java.lang.ClassCastException:
> org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
> cannot be cast to org.apache.tomcat.dbcp.dbcp.DelegatingConnection
>
>
> So far, I'm using follow configuration for the connection pool
>
> <Resource name="jdbc/SIPDB"
>            auth="Container"
>            factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>            type="javax.sql.DataSource"
>            driverClassName="com.informix.jdbc.IfxDriver"
>
> url="jdbc:informix-sqli://MyHostname/database:INFORMIXSERVER=dev"
>            username="myusername"
>            password="mypassword"
>            initialSize="5"
>            maxActive="100"
>            maxIdle="30"
>            maxWait="10000"
>            removedAbandoned="true"
>            removeAbandonedTimeout="300"
>            accessToUnderlyingConnectionAllowed="true"/>
>
>
> Thanks in advance!
>
>
> -- Gerardo Velez
>
>
> On Tue, Aug 18, 2009 at 12:17 PM, James Carman
> <james@carmanconsulting.com>wrote:
>
>> You need to allow access to the underlying connection:
>>
>> http://commons.apache.org/dbcp/configuration.html
>>
>> Search for "underlying", there's a code example.
>>
>> On Tue, Aug 18, 2009 at 2:57 PM, Gerardo Velez<jgerardo.velez@gmail.com>
>> wrote:
>> > Hi!
>> >
>> > I've been working around a web application using java + informix + tomcat
>> >
>> > So my problem is at time I trieds to insert a row in some specific table
>> and
>> > after that retrieve the serial number (autoincrement id) from informix.
>> >
>> > This is the snipped of code I have and the error generated:
>> >
>> >
>> > [CODE]
>> > java.sql.Connection = conn = dataSource.getConnection();
>> > java.sql.Statement stmt = conn.createStatement();
>> >
>> > stmt.executeUpdate(insertSQL);
>> >
>> > int serial = ((IfmxStatement)stmt).getSerial();
>> >
>> > [Error]
>> > java.lang.ClassCastException:
>> > org.apache.tomcat.dbcp.dbcp.DelegatingStatement cannot be cast to
>> > com.informix.jdbc.IfmxStatement
>> >
>> >
>> > My Connection pool, looks as follow:
>> >
>> > <Resource name="jdbc/SIPDB" auth="Container" type="javax.sql.DataSource"
>> >               maxActive="100" maxIdle="30" maxWait="10000"
>> >               username="mgrnsip" password="prx217n"
>> > driverClassName="com.informix.jdbc.IfxDriver"
>> >
>> >
>> url="jdbc:informix-sqli://myhostname:myport/mydatabase:INFORMIXSERVER=dev"/>
>> >
>> >
>> > Thanks in advance!
>> >
>> > -- Gerardo Velez
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

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


Mime
View raw message