hibernate,mysql数据库,连接正常,可是数个操作后出现Cannot open connection,貌似是连接数太多,求解
<property name="hibernate.connection.provider_class">
org.hibernate.connection.C3P0ConnectionProvider
</property>
<!-- 数据库连接的名字,有点别称的意思,只是作为备注或者标识的属性 -->
<property name="myeclipse.connection.profile">MySQL</property>
<!--c3p0连接池的最大连接数-->
<property name="hibernate.c3p0.max_size">50</property>
<!--c3p0连接池的最小连接数-->
<property name="hibernate.c3p0.min_size">1</property>
<!--c3p0连接池连接的超时时长如果空闲连接的空闲超过了timeout,就会删除-->
<property name="hibernate.c3p0.timeout">1800</property>
<!--c3p0缓存Statement的数量数-->
<property name="hibernate.c3p0.max_statements">50</property>
<!-- 每隔120秒检查连接池里的空闲连接 ,单位是秒-->
<property name="hibernate.c3p0.idle_test_period">120</property>
<!-- 当连接池里面的连接用完的时候,C3P0一下获取的新的连接数 -->
<property name="hibernate.c3p0.acquire_increment">2</property>
以上是连接池信息,
org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:78)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 24 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source
我每次都关闭了session。(session.close()),难道是数据库没关闭,求高人点解啊?