When attempting to connect to a data source which is unreliable, to stop the application from hanging (i.e. waiting for a response from the DriverManager,getConnection(...) method), you can use the login timeout integer. This represents a maximum time in seconds that the data source will wait when attempting to connect to the database.
Description from Oracle Java Docs:
DriverManager.setLoginTimeout ( ) - Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database. A value of zero
specifies that the timeout is the default system timeout
if there is one; otherwise, it specifies that there is no timeout.
When a
DataSource
object is created, the login timeout is
initially zero.
DriverManager.getLoginTimeout( ) - Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database. A value of zero
means that the timeout is the default system timeout
if there is one; otherwise, it means that there is no timeout.
When a
DataSource
object is created, the login timeout is
initially zero.
No comments:
Post a Comment