[英]JDBC getConnection timeout issue
I have an application that uses connection pooling to get database connection from an Oracle9i release 9.2.0.4 database. 我有一个使用连接池从Oracle9i 9.2.0.4版数据库获取数据库连接的应用程序。 Application is hosted in SJSAS 8.1 and the driver is
ojdbc14.jar
version 10.1.0.4. 应用程序托管在SJSAS 8.1中,驱动程序是
ojdbc14.jar
10.1.0.4版。
The problem I'm having is datasource.getConnection()
method is taking about 40 secs to throw an exception when the DB is down! 我遇到的问题是,当数据库关闭时,
datasource.getConnection()
方法大约需要40秒才能引发异常! This is causing the application to get overloaded during a DB outage. 这导致应用程序在数据库中断期间过载。 I tried setting
LoginTimeout=8
with the datasource but it has no effect. 我尝试使用数据源设置
LoginTimeout=8
,但没有任何效果。
Please see below the datasource I'm using 请在下面查看我正在使用的数据源
<jdbc-connection-pool connection-validation-method="table"
datasource-classname="oracle.jdbc.pool.OracleDataSource"
fail-all-connections="true"
idle-time out-in-seconds="600"
is-connection-validation-required="true"
is-isolation-level-guaranteed="false"
max-pool-size="100"
max-wait-time-in-millis="8000"
name="mydb"
pool-resize-quantity="80"
res-type="javax.sql.DataSource"
steady-pool-size="20"
validation-table-name="dual">
<property name="url" value="jdbc:oracle:thin:@server1:1521:mydb"/>
<property name="user" value="user1"/>
<property name="LoginTimeout" value="8"/>
<property name="password" value="pass1"/>
</jdbc-connection-pool>
Can any one please help? 有人可以帮忙吗? I need the
getConnection()
method to timeout with in the timeout given. 我需要使用
getConnection()
方法在给定的超时时间内超时。
Here's a few things to try: 这里有一些尝试:
From "Oracle® Database JDBC Developer's Guide and Reference". 摘自《Oracle®数据库JDBC开发人员指南和参考》。
Using JDBC with Firewalls 将JDBC与防火墙一起使用
Firewall timeout for idle-connections may sever a connection. 空闲连接的防火墙超时可能会切断连接。 This can cause JDBC applications to hang while waiting for a connection.
这可能会导致JDBC应用程序在等待连接时挂起。 You can perform one or more of the following actions to avoid connections from being severed due to firewall timeout:
您可以执行以下一项或多项操作,以避免由于防火墙超时而断开连接:
oracle.net.READ_TIMEOUT
as connection property to enable read timeout on socket. oracle.net.READ_TIMEOUT
作为连接属性以启用套接字上的读取超时。 The timeout value is in milliseconds. tcp_keepalive_interval
. tcp_keepalive_interval
设置一个较低的值。 SQLNET.EXPIRE_TIME=1
in the sqlnet.ora
file on the server-side. sqlnet.ora
文件中设置SQLNET.EXPIRE_TIME=1
来启用Oracle Net DCD。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.