org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Could not open connection
at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:514).....
把数据源换成c3p0也不行,求大神!!
Could not open Hibernate Session for transaction;
应该是数据库连接未设置自动重连的属性或者是数据库的jdbc驱动不能支持重连
你检查下你的连接池属性配置
mysql的重连autoReconnect参数不能使连接重连
c3p0连接池支持重连;重连参数是:
idleConnectionTestPeriod 设置空闲连接测试周期
preferredTestQuery : 设置一查询语句,用于重连测试
testConnectionOnCheckin设置为true
testConnectionOnCheckout设置为true
testConnectionOnCheckout设置为true
4.2.8你应该用的是LocalSessionFactoryBean。这个你要进行数据库操作时必须开启Transaction,否则报上面错误