ssh 事务不能回滚 Could not roll back Hibernate transaction; nested exception is org.hibernate.Transaction

调试没问题,发布到服务器上一段时间报以下异常

org.springframework.transaction.TransactionSystemException: Could not roll back Hibernate transaction; nested exception is org.hibernate.TransactionException: JDBC rollback failed
org.springframework.orm.hibernate3.HibernateTransactionManager.doRollback(HibernateTransactionManager.java:677)

问题原因:mysql 数据库将hibernate 连接给关闭了,

解决1:

hibernate配置数据源

proxool数据源

在src目录下添加Proxool.xml文件与struts.xml hiberntate.xml同目录

<?xml version="1.0" encoding="UTF-8"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
  <proxool>
   <alias>DBPool</alias>
    <driver-url>jdbc:mysql://localhost:3306/house</driver-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <driver-properties>
      <property name="user" value="root"/>
      <property name="password" value="admin"/>
    </driver-properties>
    <maximum-connection-count>10</maximum-connection-count>
    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql> 
    </proxool>
</something-else-entirely>
hiberante配置 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
		<property name="hibernate.proxool.pool_alias">DBPool</property>
		<property name="hibernate.proxool.xml">Proxool.xml</property>
		<property name="show_sql">true</property>
		<!--不删除原数据-->
		<property name="hbm2ddl.auto">update</property>

		<mapping resource="com/Allean/bean2/UserBean.hbm.xml" />
		<mapping resource="com/Allean/bean2/HouseAPK.hbm.xml" />
	</session-factory>
</hibernate-configuration>

c3p0数据源

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		
		 <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> 
			<property name="hibernate.c3p0.max_size">20</property>
			<property name="hibernate.c3p0.min_size">5</property> 
			<property name="hibernate.c3p0.timeout">120</property> 
			<property name="hibernate.c3p0.max_statements">100</property> 
			<property name="hibernate.c3p0.idle_test_period">120</property> 
			<property name="hibernate.c3p0.acquire_increment">2</property> 
			<property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
			<property name="hibernate.connection.password">admin</property> 
			<property name="hibernate.connection.url">jdbc:mysql://********2</property> 
			<property name="hibernate.connection.username">admin</property>
			<property name="hibernate.connection.password">admin</property>
			<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/house</property> 
			<property name="hibernate.connection.username">root</property>
			<property name="current_session_context_class">thread</property>
			<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> 
			<property name="hibernate.hbm2ddl.auto">update</property> 


		<mapping resource="com/Allean/bean2/UserBean.hbm.xml" />
		<mapping resource="com/Allean/bean2/HouseAPK.hbm.xml" />
	</session-factory>
</hibernate-configuration>

二、修入mysql my.ini文件 找到这个位置

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
wait_timeout=1814400 
# The TCP/IP Port the MySQL Server will listen on
port=3306

主要是修秘诀wait-timeout  单位是秒 设的值表示21天

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值