mysql连接耗尽_避免数据库连接被耗尽的三种配置

3b08456407a36064ab6a8a73f2c14066.png

避免数据库连接被耗尽的三种配置

中文社区 (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 us7e74ff1c5e8f568c56d47081985382cf.png3dc927bdb53c435567ade7cd8caeb170.pngb134db6bb64e3626c8e74a908ba90592.png | Legal Notices | Terms of Use

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值