我在Glassfish服务器v3上与Oracle 12 DB一起在Windows Server 2012 64bit下的同一台机器上运行Java EE应用程序。我使用最新的ojdbc7驱动程序。
连接池配置:
<jdbc-connection-pool validation-table-name="DUAL" steady-pool-size="20" statement-cache-size="100" associate-with-thread="true" statement-timeout-in-seconds="30" idle-timeout-in-seconds="60" max-wait-time-in-millis="2000" validate-atmost-once-period-in-seconds="20" datasource-classname="oracle.jdbc.pool.OracleDataSource" pool-resize-quantity="5" max-pool-size="60" res-type="javax.sql.DataSource" name="dbPool" is-connection-validation-required="true">
<property name="driverClass" value="oracle.jdbc.OracleDriver"></property>
<property name="user" value="xxx"></property>
<property name="url" value="jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))"></property>
<property name="password" value="xxx"></property>
<property name="portNumber" value="1521"></property>
<property name="databaseName" value="orcl"></property>
<property name="serverName" value="127.0.0.1"></property>
<property name="oracle.jdbc.ReadTimeout" value="300000"></property>
<property name="oracle.net.CONNECT_TIMEOUT" value="10000"></property>
</jdbc-connection-pool>
在2或3个小时后,当有超过1个用户(3-5)使用我的应用程序时,它会停止响应,我在glassfish日志中得到这个
javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator|_ThreadID=152;_ThreadName=Thread-2;|RAR5038:Unexpected exception while creating resource for pool dbPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: IO Error: Socket read timed out
[...]
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: IO Error: Socket read timed out
从数据库方面看起来像这样
Fatal NI connect error 12560, connecting to:
(LOCAL=NO)
VERSION INFORMATION:
TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 12.1.0.1.0 - Production
Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 12.1.0.1.0 - Production
Time: 13-JUN-2014 03:14:49
Tracing not turned on.
Tns error struct:
ns main err code: 12560
TNS-12560: TNS:protocol adapter error
ns secondary err code: 0
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0
opiodr aborting process unknown ospid (3404) as a result of ORA-609
当我只重置数据库监听器时,一切正常,接下来的1-2小时(取决于应用程序负载)。因此,临时解决方案是从Windows调度程序运行bat脚本,每隔1小时重置一次监听器。
我尝试了所有可以找到的东西 - 应用了这些参数:
- Sqlnet.ora:
SQLNET.INBOUND_CONNECT_TIMEOUT=180
SQLNET.EXPIRE_TIME=5
- Listener.ora:
INBOUND_CONNECT_TIMEOUT_LISTENER_IPC=120
但仍然没有成功