休眠+ c3p0 + SQL服务器

发布于 2024-11-30 05:01:17 字数 1735 浏览 2 评论 0原文

我用 HIBERNATE 和 SQL Server 制作服务器。当我使用 c3p0 连接池并进行负载测试时,我在 java 中获得锁定(在 c3p0 中)。

在线程转储中我看到:

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)
...

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)

一段时间后所有线程都被锁定。

但是如果我使用内部休眠连接池 - 一切都可以。我没有看到任何锁。但我不能使用内部 hibernate 连接池,因为它不用于生产(来自 Hibernate 文档)。

有人可以帮助我吗?

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 use internal hibernate connection pool because it not for production (from Hibernate docs).

Can someone help me, please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼忆七猫命九 2024-12-07 05:01:17

我听说c3p0已经死了,你最好用别的东西。
如果您使用 Tomcat,您可以使用 Apache Tomcat 池,
否则,请检查此线程 Java JDBC 连接池库选择 in 2011/2012?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文