调试没问题,发布到服务器上一段时间报以下异常
: Could not roll back Hibernate transaction; nested exception is : JDBC rollback failed
.(:677)
问题原因:mysql 数据库将hibernate 连接给关闭了,
解决1:
hibernate配置数据源
proxool数据源
在src目录下添加文件与 同目录
<?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></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"
"/hibernate-configuration-3.">
<hibernate-configuration>
<session-factory>
<property name=".provider_class"></property>
<property name=".pool_alias">DBPool</property>
<property name=""></property>
<property name="show_sql">true</property>
<!--不删除原数据-->
<property name="">update</property>
<mapping resource="com/Allean/bean2/" />
<mapping resource="com/Allean/bean2/" />
</session-factory>
</hibernate-configuration>
c3p0数据源
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"/hibernate-configuration-3.">
<hibernate-configuration>
<session-factory>
<property name=".provider_class">.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.">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"></property>
<property name="">admin</property>
<property name="">jdbc:mysql://********2</property>
<property name="">admin</property>
<property name="">admin</property>
<property name="">jdbc:mysql://localhost:3306/house</property>
<property name="">root</property>
<property name="current_session_context_class">thread</property>
<property name="">.MySQL5Dialect</property>
<property name="hibernate.">update</property>
<mapping resource="com/Allean/bean2/" />
<mapping resource="com/Allean/bean2/" />
</session-factory>
</hibernate-configuration>
二、修入mysql 文件 找到这个位置
# 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天