我正在尝试关注JDBC URL和属性,但它不能使用autoReconnect=true
。
<properties>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/gift20da_jobportal?autoReconnect=true</property>
<property name="hibernate.connection.username">gift20da_jobportal</property>
<property name="hibernate.connection.password">Jobportal@job</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
</properties>
还有其他方法可以保持连接吗?
答案 0 :(得分:0)
这解决了我的问题。
<!-- Sessions and transactions -->
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="current_session_context_class">thread</property>
在hibernate.cfg.xml中添加此代码,以供参考http://liferay-portlets.blogspot.in/2009/01/meanwhile-hibernate-mysql-problems.html。