Reputation: 301
I am working on Spring+Hibernate+JSF but if i am ideal on a page for few minute i am getting exception when trying some Database query
The last packet successfully received from the server was 2,615,049 milliseconds ago. The last packet sent successfully to the server was 27 milliseconds ago.
Caused by: org.hibernate.TransactionException: JDBC begin transaction failed:
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:76)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1309)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:474)
... 46 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Is this issue due to any configuration in my project or its database vendor issue in web.xml i made this entry
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
Connection pool
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://IP:3306/ccc" />
<property name="user" value=" hariom" />
<property name="password" value="password" />
<property name="maxPoolSize" value="2" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="1" />
</bean>
Upvotes: 0
Views: 1078
Reputation: 496
You should add this property ;
<property name="validationQuery" value="SELECT 1" />
This will validate the connection ,and if mysql closed the connection your app won't try to send packet.
Upvotes: 1