我使用 Spring + Hibernate + MySQL + Tomcat + Heroku(免费帐号)。当我开始使用网站时,一切正常,但如果我不使用db-connection页面一段时间db drop连接。同时在IntelliJ IDEA app中保持与同一db的持续连接。怎么了?
我的persistence.xml(已注释的行已尝试选项):
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="FlatsJPA" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<!--<property name="javax.persistence.jdbc.url" value="jdbc:mysql://eu-cdbr-west-01.cleardb.com:3306/heroku_a2736c1ec063973?reconnect=true"/>-->
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://eu-cdbr-west-01.cleardb.com:3306/heroku_a2736c1ec063973?autoReconnect=true"/>
<property name="javax.persistence.jdbc.user" value="b73b29b287469f" />
<property name="javax.persistence.jdbc.password" value="password" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<!--<property name="hibernate.c3p0.min_size" value="10"/>-->
<!--<property name="hibernate.c3p0.max_size" value="280"/>-->
<!--<property name="hibernate.c3p0.timeout" value="100"/>-->
<!--<property name="hibernate.c3p0.max_statements" value="0"/>-->
<!--<property name="hibernate.c3p0.idle_test_period" value="300"/>-->
<!--<property name="hibernate.c3p0.autoCommitOnClose" value="false"/>-->
<!--<property name="hibernate.c3p0.preferredTestQuery" value="SELECT 1"/>-->
<!--<property name="hibernate.c3p0.unreturnedConnectionTimeout"-->
<!--value="60"/>-->
<!--<property name="hibernate.c3p0.min_size" value="5"/>-->
<!--<property name="hibernate.c3p0.max_size" value="20"/>-->
<!--<property name="hibernate.c3p0.timeout" value="1800"/>-->
<!--<property name="hibernate.c3p0.max_statements" value="50"/>-->
<!--<property name="hibernate.c3p0.idle_test_period" value="1800"/>-->
<!--<property name="c3p0.idleConnectionTestPeriod" value="1810"/>-->
</properties>
</persistence-unit>