Mysql Spring MVC和Hibernate在8小时后停止工作
以下xml配置文件在8小时不活动后停止工作,并出现此错误: 错误:已关闭 以下是配置文件: 我目前正在使用SpringMVC4.3.8和Hibernate4.1.9。使用MySQL的C3P0连接池。我以为用C3P0可以解决这个问题,但事实并非如此。 有人知道怎么了吗 谢谢 软件导致连接中止:recv失败- 这通常意味着存在网络错误,例如TCP超时 还为hibernate.c3p0.timeout设置timeout参数,默认值为0 hibernate.c3p0.timeout–从服务器上删除空闲连接时 我排在第二位。休眠默认值:0,永不过期 设置autoReconnect,hibernate.c3p0.autoReconnect=true或作为url连接参数:jdbc:mysql://localhost:3306/test?autoReconnect=true 添加Mysql Spring MVC和Hibernate在8小时后停止工作,mysql,xml,spring,hibernate,configuration,Mysql,Xml,Spring,Hibernate,Configuration,以下xml配置文件在8小时不活动后停止工作,并出现此错误: 错误:已关闭 以下是配置文件: 我目前正在使用SpringMVC4.3.8和Hibernate4.1.9。使用MySQL的C3P0连接池。我以为用C3P0可以解决这个问题,但事实并非如此。 有人知道怎么了吗 谢谢 软件导致连接中止:recv失败- 这通常意味着存在网络错误,例如TCP超时 还为hibernate.c3p0.timeout设置timeout参数,默认值为0 hibernate.c3p0.timeout–从服务器上删除空
并检查它的日志,c3p0执行itif不添加实际选择计数1从实际表与限制1。同时检查您的网络超时我在google cloud sql中遇到过这个问题,sql服务器在空闲时间超过10小时后中断了所有连接。但在应用程序中,我们仍然有sessionFactory实例,可以创建会话,但当您实际触发db查询时,它会失败,并出现连接中断异常 以下尝试均无效。 1.在连接url中设置自动重新连接 2.xml文件中的自动重新连接、超时、验证属性。
3.编写了一个轮询服务,每8小时调用一次jdbc,以保持连接处于活动状态我曾经在google cloud sql中遇到过这样的问题,sql服务器在空闲时间超过10小时后中断所有连接。但在应用程序中,我们仍然有sessionFactory实例,可以创建会话,但当您实际触发db查询时,它会失败,并出现连接中断异常 以下尝试均无效。 1.在连接url中设置自动重新连接 2.xml文件中的自动重新连接、超时、验证属性。
3.编写了一个轮询服务以进行jdbc调用,使连接每8小时保持活动状态添加了新选项Config您是否在日志文件中看到slect 1?检查网络超时。作为您的networ管理员超时。您是什么应用程序服务器?tomcat?是,服务器是tomcat。添加了新选项Config您是否在日志文件中看到slect 1?检查网络超时。作为networ管理员超时。您的应用程序服务器是什么?tomcat?是的,服务器是tomcat。
25-may-2017 8:45:23 org.apache.catalina.core.StandardWrapperValve invoke
Servlet.service() for servlet [dispatcher] in the context with path [/system] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin transaction failed: ] with root cause:
java.net.SocketException: **Software caused connection abort: recv failed**
<context:component-scan base-package="es.company.system.persistence" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="es.mypackage.model"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="connection.url" value="jdbc:mysql://localhost:3306/system" />
<property name="connection.username" value="???" />
<property name="connection.password" value="???" />
<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.testConnectionOnCheckout" value="true" />
<property name="hibernate.c3p0.privilegeSpawnedThreads" value="true" />
<property name="hibernate.c3p0.contextClassLoaderSource" value="library" />
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<tx:annotation-driven transaction-manager="transactionManager" />