commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Otto Cordero" <ocord...@sipecom.com>
Subject [dbcp] Exception when using tdk 2.2
Date Thu, 13 Feb 2003 18:28:19 GMT
Hi All,

We are migrating our app (running with turbine and dbcp) to TDK 2.2 from
2.1. This change causes an exception to occur when the PoolingDataSource
retrieves a connection:

java.lang.NullPointerException
 at
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.ja
va:110)

I checked the code and the line 110 just returns pool.borrowObject. More
strange it is, that I called the borrowObject() method directly from my pool
and it returned the connection.

Do you know what is causing this error. I guess it is some conflict with the
libraries, what can it be?

Thanks.

Otto.


PS: the code looks like this:

ObjectPool connectionPool
            = new GenericObjectPool(null);
        ConnectionFactory connectionFactory
            = new DriverConnectionFactory(
                    (Driver)Class.forName(driver).newInstance()
                    ,connectURI, props);

        PoolableConnectionFactory poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,t
rue);
        PoolingDataSource dSource = new PoolingDataSource(connectionPool);

nothing new I guess...

----- Original Message -----
From: "Craig R. McClanahan" <craigmcc@apache.org>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Tuesday, November 12, 2002 1:03 PM
Subject: Re: [ DBCP | MySQL | Tomcat ] Occasional IOException
w/ps.executeQuery();


>
>
>
>
> On Tue, 12 Nov 2002, Garrett Smith wrote:
>
> > Date: Tue, 12 Nov 2002 08:38:24 -0800 (PST)
> > From: Garrett Smith <javadevmac@yahoo.com>
> > Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> > To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> > Subject: Re: [ DBCP | MySQL | Tomcat ]  Occasional IOException
> >     w/ps.executeQuery();
> >
> > I wonder,
> >
> > I am having an occasional connection problem:
> >
> > java.sql.SQLException: Communication link failure: java.io.IOException
> >    at org.gjt.mm.mysql.MysqlIO.clearAllReceive(Unknown Source)
> >    at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)
> >    at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)
> >    at org.gjt.mm.mysql.PreparedStatement.executeQuery(Unknown Source)
> >    at
> >
>
org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingP
reparedStatement.java:179)
>
> >    at com.dhtmlkitchen.reg.db.Database.login(Database.java:159)
> >
>
> You're likely to encounter problems like this if your database is shut
> down and restarted while the Java application is running (i.e. while the
> pool is already in existence).  In addition, some databases impose
> timeouts on the connection, and (from the database) shut down the socket
> if it hasn't been used for a while.
>
> The solution to either is to configure your data source to perform a
> "validation query" before returning a connection via the getConnection()
> method.  If the pool finds that the validation query throws an exception,
> it assumes that one of the two above problems has occurred, and throws
> this connection away.
>
> If you're using the standard Tomcat 4.1 support for JNDI resources (which
> uses commons-dbcp), you set this up with a "validationQuery" property in
> the <ResourceParams> section.  The value should be an SQL SELECT statement
> that runs very quickly (because it will get used on every call to
> getConnection()).
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:commons-user-help@jakarta.apache.org>
>


Mime
View raw message