too many connections

来源:互联网 发布:wp 添加js 编辑:程序博客网 时间:2024/05/16 12:45
在使用hibernate 配置了c3p0数据库以后
在Dao中使用getsession以后 多进行几次查询就报错 报错too many connections
观察发现 是使用线程池的时候 当我们取到数据连接以后 使用完后并没有进行释放
 查看配置数据库
并没有配置
<property name="maxIdleTime" value="${jdbc.maxIdleTime}"></property>
<!--最大空闲时间,多少秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
  <property name="maxStatements" value="${jdbc.maxStatements}"></property>

<!--JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements

属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。

如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0-->

另外加上配置datasource 时加上destroy-method="close"方法

使不用的链接回到数据连接池
0 0
原创粉丝点击