c3p0连接管理问题

发布于 2024-08-29 03:53:06 字数 1474 浏览 10 评论 0原文

我正在使用 Spring 3.0.2、Hibernate 3.5.0 和 c3p0 0.9.1.2,当涉及到检索连接和提交事务时,我遇到了大量错误。这是我的 c3p0 配置:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}"/>
    <property name="jdbcUrl" value="${jdbc.url}"/>
    <property name="properties">
        <props>
            <prop key="c3p0.acquireIncrement">5</prop>
            <prop key="c3p0.maxIdleTime">30</prop>
            <prop key="c3p0.idleConnectionTestPeriod">20</prop>
            <prop key="c3p0.maxPoolSize">100</prop>
            <prop key="c3p0.maxStatements">0</prop>
            <prop key="c3p0.minPoolSize">1</prop>
            <prop key="user">${jdbc.username}</prop>
            <prop key="password">${jdbc.password}</prop>
        </props>
    </property>
</bean>

直到最近我经常收到此错误:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.

最近我也收到这些:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
java.sql.SQLException: Connections could not be acquired from the underlying database!

有什么建议吗?

I'm using Spring 3.0.2, Hibernate 3.5.0 and c3p0 0.9.1.2 and I'm having a ton of errors when it comes down to retrieving connections and commiting transactions. Here's my configuration of c3p0:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}"/>
    <property name="jdbcUrl" value="${jdbc.url}"/>
    <property name="properties">
        <props>
            <prop key="c3p0.acquireIncrement">5</prop>
            <prop key="c3p0.maxIdleTime">30</prop>
            <prop key="c3p0.idleConnectionTestPeriod">20</prop>
            <prop key="c3p0.maxPoolSize">100</prop>
            <prop key="c3p0.maxStatements">0</prop>
            <prop key="c3p0.minPoolSize">1</prop>
            <prop key="user">${jdbc.username}</prop>
            <prop key="password">${jdbc.password}</prop>
        </props>
    </property>
</bean>

Up until recently I got this error pretty often:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.

Recently I also get these:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
java.sql.SQLException: Connections could not be acquired from the underlying database!

Any suggestions?

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

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

发布评论

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

评论(1

离不开的别离 2024-09-05 03:53:06

这可能是因为连接超时。检查idle_test_period设置或使用bonecp http://jolbox.com,它具有合理的默认值。

That's probably because connections are being timed out. Checkout idle_test_period setting or use bonecp http://jolbox.com which has sensible defaults instead.

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