I am writing a java service which will be deployed in Jboss server which will establish an oracle database connection. The following code will obtain a connection from the connection pool in Jboss:
If the connection is available, the available connection will be returned. However, if let's say if the database server is down, the following codes will take a very long time to throw an Exception. Is there anyway for me to set a configurable timeout value as I want it to be configurable via the service?
This will probably be a parameter on the JDBC driver or Jboss connection pool settings. I am not familiar with jboss, so can't give you the exact details. I doubt it can be set programmatically.
there are some timeout parameters in jboss. for your database connection timeouts there is a parameter idle-timeout-minutes in the *-ds.xml files in the deploy directory. also you have a transactiontimeout which is defined in conf/jboss-service.xml file it is named TransactionTimeout
so you can adjust them to appropriate values for you