JETTY部署注意的数据库连接问题
2012-05-25 10:30
239 查看
问题描述:
2012-05-25 09:34:22,712 WARN [JDBCExceptionReporter.java:100] : SQL Error: 0, SQLState: 08S01
2012-05-25 09:34:22,714 ERROR [JDBCExceptionReporter.java:101] : The last packet successfully received from the server was65852 seconds ago.The last packet sent successfully to the server was 65852 seconds ago, which is longer than the server configured
value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to
avoid this problem.
解决方案:
修改persistence.xml文件中相关的Hibernate属性
方法一:
方法二:
2012-05-25 09:34:22,712 WARN [JDBCExceptionReporter.java:100] : SQL Error: 0, SQLState: 08S01
2012-05-25 09:34:22,714 ERROR [JDBCExceptionReporter.java:101] : The last packet successfully received from the server was65852 seconds ago.The last packet sent successfully to the server was 65852 seconds ago, which is longer than the server configured
value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to
avoid this problem.
解决方案:
修改persistence.xml文件中相关的Hibernate属性
方法一:
<properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306?characterEncoding=utf-8" /> <property name="hibernate.connection.username" value="root" /> <property name="hibernate.connection.password" value="123" /> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" /> <property name="hibernate.connection.url" value="jdbc:mysql://server/dbname?autoReconnect=true" /> <property name="hibernate.show_sql" value="false" /> <!-- 自动检测空闲时间,MySQL默认的timeout时间为8小时,此处设定为每25200秒检测一次,下面的单位为秒 --> <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="25200" /> <property name="hibernate.c3p0.preferredTestQuery" value="select 1;" /> </properties>
方法二:
<property name="hibernate.connection.url" value="jdbc:mysql://server/dbname?autoReconnect=true" /> <property name="hibernate.connection.autoReconnect" value="true" /> <property name="hibernate.connection.autoReconnectForPools" value="true" />
相关文章推荐
- 关于部署tomcat 连接数据库的问题
- 在用ORACLE数据库和JSP连接时要注意的一些问题精粹
- AOS更换所连接的数据库要注意的问题
- Linq to Entity中连接两个数据库时要注意的问题
- 解决 web服务器部署常见问题,server application unavailable 和 程序无法连接数据库 的问题(asp.net 2.0 + oracle9i + winXP)
- java 连接 SQL server 数据库时 出现的问题,特别需要注意(包括 版本 区别)
- 传参出错注意数据库连接问题
- SSH+Easyui应用部署至新浪服务器数据库连接及问题
- 解决 web服务器部署常见问题,server application unavailable 和 程序无法连接数据库 的问题(asp.net 2.0 + oracle9i + winXP)
- 使用C#通过Oracle.DataAccess连接Oracle,部署时需要注意版本问题
- 在用ORACLE数据库和JSP连接时要注意的一些问题精粹
- 连接SQL Server 2005数据库需要注意的问题
- JDBC连接数据库时注意的小问题~~
- JSP开发WEB程序时注意的问题(中文化,数据库连接,目录)
- 关于部署完asp.net程序后不能访问页面也不能连接数据库的问题
- delphi连接SQL2005做的数据库管理系统的一些部署问题
- 数据库左右外连接与mapper.xml注意问题
- 使用C#通过Oracle.DataAccess连接Oracle,部署时需要注意版本问题
- 基于服务的数据库连接注意的问题
- ORA-02041: 客户数据库未开始一个事务处理 .NET 连接低版本ORACLE时需要注意的问题