Hibernate + c3p0 + SQL Server
I make server with HIBERNATE and SQL Server. When I use c3p0 connection pool and make load test I get lock in java (in c3p0).
In threads dump I see:
at java.lang.Object.wait(Object.java:-1)
at java.lang.Object.wait(Object.java:485)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.acquireStatement(GooGooStatementCache.java:552)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.checkoutStatement(GooGooStatementCache.java:168)
at com.mchange.v2.c3p0.impl.NewPooledConnection.checkoutStatement(NewPooledConnection.java:234)
- locked <0x124d> (a com.mchange.v2.c3p0.impl.NewPooledConnection)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:199)
- locked <0x124e> (a com.mchange.v2.c3p0.impl.NewProxyConnection)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
...
or
at java.lang.Object.wait(Object.java:-1)
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1315)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
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)
and after some time all the threads are locked.
But If I use internal hibernate connection pool - all ok. I don't see any locks. But I can't u开发者_C百科se internal hibernate connection pool because it not for production (from Hibernate docs).
Can someone help me, please.
I heard that c3p0 is dead, you'd better use something else. In case you use Tomcat, you can go for Apache Tomcat pool, otherwise, check this thread Java JDBC connection pool library choice in 2011/2012?
精彩评论