Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DBCP Connection Pool loginTimeout

According to the DBCP Document, BasicDataSource does not support setLoginTimeout(). My question is then how do I set a LoginTimeout for the creation of Connection objects? I know I can set maxWait on the pool, but my understanding is that that'll only be used for when the pool is exhausted and you're waiting for an existing connection to free up. It will not save me from the situation where a new connection needs to be created, but the connection/login into the DB hangs.

Any help is appreciated. Thanks.

like image 590
RAY Avatar asked Jul 03 '12 08:07

RAY


People also ask

What is DBCP connection pool?

The DBCP Component Opening a connection per user can be unfeasible in a publicly-hosted Internet application where the number of simultaneous users can be very large. Accordingly, developers often wish to share a "pool" of open connections between all of the application's current users.

What is JDBC connection pool size?

The connection pool configuration settings are: Initial and Minimum Pool Size: Minimum and initial number of connections maintained in the pool (default is 8) Maximum Pool Size: Maximum number of connections that can be created to satisfy client requests (default is 32)

How to set connection timeout in JDBC?

The JDBC standard (2.0/3.0) does not support setting of the connection timeout. solidDB ® has introduced two ways for doing that: one using a non-standard driver manager extension method and the other one using the property mechanisms. The time unit in either case is one millisecond.

What is BasicDataSource?

public class BasicDataSource extends Object implements DataSource, BasicDataSourceMXBean, MBeanRegistration, AutoCloseable. Basic implementation of javax. sql. DataSource that is configured via JavaBeans properties.


1 Answers

Well there is always an option to add correct parameter to the URL. Depending on which DB you are using you can add one of the parameters in JDBC url.

Here is the link that confirms that BasicDataSource does not support loginTimeout

And at the bottom of this blog There is a table which lists URL parameters for connection timeouts.

like image 186
Sap Avatar answered Oct 11 '22 08:10

Sap