避免数据库连接被耗尽的三种配置
中文社区 (MOSC)
中间件 (MOSC)
0 Replies
Last updated on February 15, 2015
This question is Not Answered.
1 自动恢复泄露的数据库连接
在 Admin Console -> JDBC Data Source: Configuration: Connection Pool, 设置 "Inactive Connection Timeout" 大于0的值。
WebLogic Server 会强制回收泄露的连接。有两种泄露情形,一种是应用程序员没有调用 javax.sql.Connection.close() 方法还回连接到连接池。 另外一种是应用程序借得连接后执行的SQL长时间运行没有还回连接池。
Weblogic Server 会输出一个错误信息到日志文件, BEA-001153: Forcibly releasing inactive connection message is written to the server log.
2 设置 SQL Statement Timeout
在 Admin Console -> JDBC Data Source: Configuration: Connection Pool, 设置 "Statement Timeout" 大于 0 的值。
StatementTimeout 依赖于下层的 JDBC driver 实现这个特性. WebLogic Server 通过调用 JDBC driver API java.sql.Statement.setQueryTimeout() 设置 SQL Statement Timeout。当SQL 执行超过这个时长,JDBC driver 抛出异常:java.sql.SQLException: ORA-01013: user requested cancel of current operation to the server log.
3 设置 JDBC Socket Timeout
在 Admin Console -> JDBC Data Source: Configuration: Connection Pool, 设置额外的 "Properties" :
oracle.net.READ_TIMEOUT=30000
oracle.jdbc.ReadTimeout=30000
单位是毫秒, READ_TIMEOUT 适合 11g 以前的 JDBC driver。ReadTimeout适用于 11g 和以后版本 JDBC driver。
这个特性是To view full details, sign in with your My Oracle Support Community account.
Don't have a My Oracle Support
Community account? Click to get started!
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.
Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. For more information about Oracle (NYSE:ORCL), visit oracle.com. © Oracle | Contact and Chat | Support | Communities | Connect with us | Legal Notices | Terms of Use