在尝试按照我能找到的所有示例配置 c3p0 之后,我仍然遇到 JDBC 超时。我正在使用 JPA、Hibernate、Tomcat、MySQL [AWS RDS]。这是persistence.xml的片段:
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://url..." />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.acquire_increment" value="4" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
<property name="hibernate.c3p0.max_size" value="100" />
<property name="hibernate.c3p0.max_statements" value="15" />
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.timeout" value="100" />
和错误日志:
09:18:51.776 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 08S01
09:18:51.777 ERROR org.hibernate.util.JDBCExceptionReporter - The last packet successfully received from the server was 38,491,585 milliseconds ago. ...