Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 949445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:24:13+00:00 2026-05-15T23:24:13+00:00

Let me describe my question – I have a Java application – Hibernate as

  • 0

Let me describe my question –

I have a Java application – Hibernate as the DB interfacing layer over MySQL. I get the communications link failure error in my application. The occurence of this error is a very specific case. I get this error , When I leave mysql server unattended for more than approximately 6 hours (i.e. when there are no queries issued to MySQL for more than approximately 6 hours). I am pasting a top ‘exception’ level description below, and adding a pastebin link for a detailed stacktrace description.

javax.persistence.PersistenceException:
org.hibernate.exception.JDBCConnectionException:
Cannot open connection
– Caused by: org.hibernate.exception.JDBCConnectionException:
Cannot open connection
– Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
– The last packet successfully received from the server was
1,274,868,181,212 milliseconds ago.
The last packet sent successfully to
the server was 0 milliseconds ago.
– Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
– The last packet successfully received from the server was
1,274,868,181,212 milliseconds ago.
The last packet sent successfully to
the server was 0 milliseconds ago.
– Caused by: java.net.ConnectException: Connection
refused: connect

the link to the pastebin for further investigation – http://pastebin.com/4KujAmgD

What I understand from these exception statements is that MySQL is refusing to take in any connections after a period of idle/nil activity. I have been reading up a bit about this via google search, and came to know that one of the possible ways to overcome this is to set values for c3p0 properties as c3p0 comes bundled with Hibernate. Specifically, I read from here http://www.mchange.com/projects/c3p0/index.html that setting two properties idleConnectionTestPeriod and preferredTestQuery will solve this for me. But these values dont seem to have had an effect.

Is this the correct approach to fixing this? If not, what is the right way to get over this?

The following are related Communications Link Failure questions at stackoverflow.com, but I’ve not found a satisfactory answer in their answers.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure
How to handle: Communication link failure

Note 1 – i dont get this error when I am using my application continuosly.
Note 2 – I use JPA with Hibernate and hence my hibernate.dialect,etc hibernate properties reside within the persistence.xml in the META-INF folder (does that prevent the c3p0 properties from working?)

edit –
the c3p0 parameters I tried out are in the comments

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:24:13+00:00Added an answer on May 15, 2026 at 11:24 pm

    I had issue before. It looks like MySQL server times out your connection.
    Timeout is 28800 by default which is 8 hours. Please refer to this link for more details.

    http://shengchien.blogspot.com/2009/10/hibernate-c3p0-and-mysql.html

    Hope it is useful to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.