hibernate基础知识备份

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
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值