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.
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.
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)
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.
public class BasicDataSource extends Object implements DataSource, BasicDataSourceMXBean, MBeanRegistration, AutoCloseable. Basic implementation of javax. sql. DataSource that is configured via JavaBeans properties.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With