標籤:java.net.sockettimeoutexception: read timed out nested exception is org.hibernate.transactionexception: jdbc commit failed jdbc jdbc錯誤
項目結構是:springmvc +hibernate+mysql,
資料庫連接池:C3P0
伺服器使用的是tomcat7
出現的狀況是:訪問的時候經常出現404錯誤
實驗的過程剛開始以為是資料庫版本的問題,但是用過了各個版本,包括作業系統用windows,linux都試過,錯誤是一樣的。
也試過網路上面講的改變mysql的設定檔,增加連線時間,但是錯誤依舊。
在和我們公司的汪總和程式員溝通之後,終於得到解決。
原因是
HIBERNATE的配置不一定能管理動C3P0
出現的錯誤提示:
|
HTTP Status 500 - Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: JDBC commit failed; nested exception is org.hibernate.TransactionException: JDBC commit failed
type Exception report
message Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: JDBC commit failed; nested exception is org.hibernate.TransactionException: JDBC commit failed
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: JDBC commit failed; nested exception is org.hibernate.TransactionException: JDBC commit failed
org.springframework.orm.hibernate3.HibernateSystemException: JDBC commit failed; nested exception is org.hibernate.TransactionException: JDBC commit failed
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 149,464 milliseconds ago. The last packet sent successfully to the server was 18,923 milliseconds ago.
java.net.SocketTimeoutException: Read timed out
|
解決問題的辦法是改變spring的設定檔applicationContext.xml,增加相關的配置
在<beans>標籤內加入下面相關的配置:
|
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driver}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialPoolSize" value="${connection_pools.initial_pool_size}" />
<property name="minPoolSize" value="${connection_pools.min_pool_size}" />
<property name="maxPoolSize" value="${connection_pools.max_pool_size}" />
<property name="maxIdleTime" value="${connection_pools.max_idle_time}" />
<property name="acquireIncrement" value="${connection_pools.acquire_increment}" />
<property name="checkoutTimeout" value="${connection_pools.checkout_timeout}" />
<property name="testConnectionOnCheckin" value="false"/>
<property name="testConnectionOnCheckout" value="true"/>
<property name="preferredTestQuery" value="SELECT 1"/>
</bean> |
配置完重啟伺服器就可以了
本文出自 “7422562” 部落格,請務必保留此出處http://7432562.blog.51cto.com/7422562/1577594
Hibernate 對c3p0配置不支援導致的錯誤