This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes DataSource getConnection() configuring new connection timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DataSource getConnection() configuring new connection timeout" Watch "DataSource getConnection() configuring new connection timeout" New topic
Author

DataSource getConnection() configuring new connection timeout

Allan Brockenbrough
Greenhorn

Joined: Nov 07, 2008
Posts: 1
I'm having a problem configuring the timeout that is used when establishing a new connection to an Oracle database when using a connection pool.

I'm using DBCP in Tomcat and XML to configure the resource (below). I'm using the oracle thin jdbc.

In the source code I get a DataSource and connection like this:

DataSource ds = (DataSource) envCtx.lookup("jdbc/anncDB");
Connection conn = ds.getConnection();

This works fine if the IP specified in the url is available. But if it is not available, it takes 3 minutes before getConnection() returns. I need to configure this to be smaller.

I've tried setLoginTimeout(), but that doesn't work. Doing ds.setLoginTimeout() takes 3 minutes before failing.

Any ideas?

Allan
-------

<Context path="/aeservlet">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="aeservlet." suffix=".log" timestamp="true"/>
<Resource name="jdbc/anncDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="10"
maxIdle="1"
maxWait="5000"
username="xxxx"
password="xxxx"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbcracle:thin:@10.0.0.0:1521:ODS"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
connectionProperties=""
removeAbandoned="1"
removeAbandonedTimeout="1"
description="Resource in server.xml GlobalNamingResources"/>
</Context>

Oracle driver version: v10.2.0
 
Have you checked out Aspose?
 
subject: DataSource getConnection() configuring new connection timeout
 
It's not a secret anymore!