hibernate的配置技巧
发布日期:2021-09-30 18:10:43 浏览次数:11 分类:技术文章

本文共 1096 字,大约阅读时间需要 3 分钟。

在mysql数据库中采用主从数据库配置,在读取从库的数据时读到脏数据,并且在web容器重启之后消失,在启动之后数据库中的记录变化之后,查询的数据就是不更新,原因是数据库的链接采用了不自动提交的链接并且。在hibernate的配置文件中增加如下的参数就可以解决
<property name="hibernate.connection.autocommit">true</property>
在数据库连接池链接数据库之后,数据库重启之后,web容器不重启的情况下,访问数据库的API就一直报错,
org.hibernate.exception.JDBCConnectionException: could not execute query
Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:
** BEGIN NESTED EXCEPTION **
com.mysql.jdbc.CommunicationsException
MESSAGE: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
MESSAGE: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
STACKTRACE:
java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
在hibernate的配置文件中增加如下的参数就可以解决
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

转载地址:https://blog.csdn.net/iteye_10343/article/details/82360039 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:smslib发送短信
下一篇:MySQL之alter语句用法总结

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月10日 15时55分55秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章