1.如果要修改某行数据的某个值,先得到这个对象实例,然后set需要更新的属性,然后update。
2.hibernate在8小时内不对mysql进行操作时,会导致8小时后访问不到MYSQL,因为MYSQL默认是8小时后抛弃闲置链接,
原文MySQL closes connections after 8 hours of inactivity. You either need to use a connection pool that handles stale connections or use the "autoReconnect" parameter (see "Developing Applications with MySQL Connector/J").
Also, you should be catching SQLExceptions in your application and dealing with them, rather than propagating them all the way until your application exits, this is just good programming practice. MySQL Connector/J will set the SQLState (see java.sql.SQLException.getSQLState() in your APIDOCS) to "08S01" when it encounters network-connectivity issues during the processing of a query. Your application code should then attempt to re-connect to MySQL at this point.
至于为什么MYSQL要这样设置,俺就不是很清楚了。
hibernate3配置文件:
先把c3p0-0.9.0.jar添加到lib里面,我是直接加到tomcat的common里面了。然后修改了自己的配置hibernate.cfg.xml,
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.validate">false</property>
我是在Eclipse里开发的,不要忘了刷新一下,重启tomcat后,我手动修改了系统时间,结果没有发生异常,此前我只要把系统时间外后顺就会跑出该异常,现在就等着明天早上再来检验否正常了。
载至:http://blog.csdn.net/bonbonstella/archive/2006/11/24/1409952.aspx
http://bjzhanghao.cnblogs.com/archive/2004/12/10/75145.html
2.hibernate在8小时内不对mysql进行操作时,会导致8小时后访问不到MYSQL,因为MYSQL默认是8小时后抛弃闲置链接,
原文MySQL closes connections after 8 hours of inactivity. You either need to use a connection pool that handles stale connections or use the "autoReconnect" parameter (see "Developing Applications with MySQL Connector/J").
Also, you should be catching SQLExceptions in your application and dealing with them, rather than propagating them all the way until your application exits, this is just good programming practice. MySQL Connector/J will set the SQLState (see java.sql.SQLException.getSQLState() in your APIDOCS) to "08S01" when it encounters network-connectivity issues during the processing of a query. Your application code should then attempt to re-connect to MySQL at this point.
至于为什么MYSQL要这样设置,俺就不是很清楚了。
hibernate3配置文件:
先把c3p0-0.9.0.jar添加到lib里面,我是直接加到tomcat的common里面了。然后修改了自己的配置hibernate.cfg.xml,
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.validate">false</property>
我是在Eclipse里开发的,不要忘了刷新一下,重启tomcat后,我手动修改了系统时间,结果没有发生异常,此前我只要把系统时间外后顺就会跑出该异常,现在就等着明天早上再来检验否正常了。
载至:http://blog.csdn.net/bonbonstella/archive/2006/11/24/1409952.aspx
http://bjzhanghao.cnblogs.com/archive/2004/12/10/75145.html