aspose file tools*
The moose likes Tomcat and the fly likes Datasource.getConnection() hangs when network goes down... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Datasource.getConnection() hangs when network goes down..." Watch "Datasource.getConnection() hangs when network goes down..." New topic
Author

Datasource.getConnection() hangs when network goes down...

soma sundaresh
Greenhorn

Joined: Jul 20, 2004
Posts: 1
Hi,
I am using commons dbcp -1.1 with Tomcat 4.1.29 for my JSP/Servlets based web application with sybase as the database.

The code just hangs in the line - Datasource.getConnection() when network is down. I tried it by plugging out the database network plug.

When I tried to reconnect to database I got the exception after about 10-12
secs -

DataSource in Cache:
org.apache.commons.dbcp.datasources.SharedPoolDataSource@b1cc87
CMS DAO - time before connection :Mon Jul 19 23:37:59 IST 2004
time taken: 360941
SQL Exception connecting to Database .Msg : Could not retrieve connection
info from pool : null => exception.getMessage()
org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection
info from pool, cause:
java.sql.SQLException: JZ0C0: Connection is already closed.
at
com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:439)
at
com.sybase.jdbc2.jdbc.SybConnection.checkConnection(SybConnection.java:1519)
at com.sybase.jdbc2.jdbc.SybConnection.close(SybConnection.java:664)
at
org.apache.commons.dbcp.cpdsadapter.PooledConnectionImpl.close(PooledConnect
ionImpl.java:160)
at
org.apache.commons.dbcp.datasources.KeyedCPDSConnectionFactory.destroyObject
(KeyedCPDSConnectionFactory.java:184)
at
org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(Unknown
Source)
at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnection
AndInfo(SharedPoolDataSource.java:213)
at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst
anceKeyDataSource.java:676)
at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst
anceKeyDataSource.java:660)
at com.xavex.dao.cmsdao.CmsDAO.connectToDatabase(CmsDAO.java:169)

Now, My issues are =>
1. Even the timeout after the plug is removed (set using MaxWait) doesnt
seem to be working consistently. It doesnt work all the time. ?
2. In the above, the net time taken is too high. Though the maxWait param
was set to 1 sec. Any way we can reduce this time ?
3. Do I have to reset the datasource after the network connection is reset.
After the connection is dropped, can I find out if the network is restored
or not ?

Am I missing something here?
Please help

Thanks
Soma
 
 
subject: Datasource.getConnection() hangs when network goes down...