Groups > DB2 > DB2 Spatial server > Re: Exception while getting a connection




Exception while getting a connection

Exception while getting a connection
Tue, 06 Feb 2007 05:23:12 EST
Hi 

  We are getting database connections in a java application using 
DB2PooledConnection where intermittently we are getting null pointer
exceptions.

  Restarting the application we were able to get connections successfully. But
again after some time we get the connection as null.


  We run that application on AIX 5.2 and connect to DB2 v8.2.1
database driver is COM.ibm.db2.app.DB2Driver.

Could anybody please help in resolving this.

Thanks
Post Reply
Re: Exception while getting a connection
Tue, 06 Feb 2007 13:18:04 +010
vvgangadharsonti@gmail.com wrote:

> Hi
> 
>   We are getting database connections in a java application using 
>   DB2PooledConnection where intermittently we are getting null pointer
>   exceptions.
> 
>   Restarting the application we were able to get connections successfully.
>   But again after some time we get the connection as null.
> 
> 
>   We run that application on AIX 5.2 and connect to DB2 v8.2.1
> database driver is COM.ibm.db2.app.DB2Driver.

I have not used DB2PooledConnections yet, but are you sure that you
use "recycleDB2Connection" to free up any unused connections?  How
many
connections do you have open against DB2 when the error occurs?  Have you
applied the latest FixPak already?

-- 
Knut Stolze
DB2 z/OS Utilities Development
Post Reply
Re: Exception while getting a connection
Thu, 08 Feb 2007 02:42:03 EST
Hi

The number of connections when we got the problem has no consistent behaviour ,
though the total number of connections to the database < 10 this problem
occured.

We did not write any code related to recycleDBConnections in our java program.
We just closed the connection after we are done with it. 

Should we use recycleDBConnection to free up the connection?? 

Could you please suggest how to use this inside the java program.

Thanks
Ganga

Post Reply
Re: Exception while getting a connection
Thu, 08 Feb 2007 03:58:44 EST
Hi 

We are using COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource and we get the pooled
connection from this Datasource which is COM.ibm.db2.jdbc.DB2PooledConnection
from which. For this I am unable to find any method like recycleDBConnection().
Please suggest a solution for this.

Below is the code to get the connection from database

	Class.forName(config.getProperty("COM.ibm.db2.jdbc.app.DB2Driver"));

		DB2ConnectionPoolDataSource db2cpds = new DB2ConnectionPoolDataSource();
		db2cpds.setDatabaseName("database");
                db2cpds.setUser("username");
                db2cpds.setPassword("password");
		db2cpds.setConnectionAttribute("url");

            db2PooledCon = (DB2PooledConnection)db2cpds.getPooledConnection();
            Connection con=db2PooledCon.getConnection(); 

Thanks
Post Reply
Re: Exception while getting a connection
Thu, 08 Feb 2007 12:40:26 +010
vvgangadharsonti@gmail.com wrote:

> Hi
> 
> We are using COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource and we get the
> pooled connection from this Datasource which is
> COM.ibm.db2.jdbc.DB2PooledConnection from which. For this I am unable to
> find any method like recycleDBConnection(). Please suggest a solution for
> this.

From my understanding, you sholud use the "recycleDBConnection" method
as
listed here in the docs:
http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.ja
va.doc/doc/r0021832.htm

-- 
Knut Stolze
DB2 z/OS Utilities Development
Post Reply
about | contact