在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>
<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>