where can set timeout getting database connection: javax.sql.datasource.getconnection() in tomcat 7 application server ?
context initcontext = new initialcontext(); context envcontext = (context) initcontext.lookup(dbmanagerconstants.context_name); datasource ds = (datasource) envcontext.lookup(dbmanagerconstants.ds_name); conn = ds.getconnection(); i have java web application on tomcat 7 connection oracle database. 1 day our net admin changed in firewall after application unable database connection still there no timeout , error. after removing change(after 1,5 hours) in firewall application continued work if nothing happened. these delayed connections finished operations successfully.
this datasource
<context> <resource name="jdbc/pds" auth="container" driverclassname="oracle.jdbc.driver.oracledriver" factory="our.encryptor.encrypteddatasourcefactory" logabandoned="true" maxactive="30" maxidle="10" maxwait="1000" password="my_password" removeabandoned="true" removeabandonedtimeout="60" type="javax.sql.datasource" url="jdbc:oracle:thin:@127.0.0.1:8080:sid" username="my_user" accesstounderlyingconnectionallowed="true" validationquery="select 1 dual" /> </context>
i believe maxwait time have set 1000 milliseconds. set -1 if want application wait every, otherwise through exception everytime wait time exceeded meaning connection attempt has timed-out.
Comments
Post a Comment