【问题标题】:how to configure a spring+hibernate+mysql project?如何配置一个spring+hibernate+mysql的项目?
【发布时间】:2016-07-25 09:41:20
【问题描述】:

我用spring3 hibernate4和struts2建一个web项目,我用c3p0,我的项目可以在我的服务器上运行,但是大约10个小时后,tomcat自动停止了,我知道这是因为我的配置文件,因为关于数据库连接,我阅读了很多文章,但仍然无法正常工作。 有我的配置

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClass}" />
    <property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
    <property name="user" value="${jdbc.user}" />
    <property name="password" value="${jdbc.password}" />

    <property name="initialPoolSize" value="3" />
    <property name="minPoolSize" value="3" />
    <property name="maxPoolSize" value="50" />
    <property name="maxIdleTime" value="7200" />
    <property name="maxStatements" value="200" />
    <property name="idleConnectionTestPeriod" value="270" />
    <property name="preferredTestQuery">
        <value>SELECT 1</value>
    </property>
</bean>

我在我的日志文件中看到了这样的警告

05-Apr-2016 18:30:32.497 WARN [localhost-startStop-1] org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure HHH000342: Could not obtain connection to query metadata : An attempt by a client to checkout a Connection has timed out.

当我关闭 tomcat 时,会出现一些错误 enter image description here

【问题讨论】:

    标签: mysql spring hibernate c3p0


    【解决方案1】:

    添加此属性:

    <property name="testConnectionOnCheckout " value="true" />
    

    查看此c3p0 步骤,了解如何通过test connection 了解更多详情

    【讨论】:

      猜你喜欢
      • 2017-07-04
      • 2020-08-06
      • 1970-01-01
      • 1970-01-01
      • 2016-04-29
      • 2015-03-07
      • 1970-01-01
      • 1970-01-01
      • 2012-11-13
      相关资源
      最近更新 更多