码迷,mamicode.com
首页 > Web开发 > 详细

Hibernate 对c3p0配置不支持导致的错误

时间:2014-11-17 19:39:58      阅读:313      评论:0      收藏:0      [点我收藏+]

标签: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配置不支持导致的错误

标签:java.net.sockettimeoutexception: read timed out   nested exception is org.hibernate.transactionexception: jdbc commit failed   jdbc   jdbc错误   

原文地址:http://7432562.blog.51cto.com/7422562/1577594

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!