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 6136229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:34:41+00:00 2026-05-23T17:34:41+00:00

I have a Java application under Tomcat, connecting to a Postgre and a MySQL

  • 0

I have a Java application under Tomcat, connecting to a Postgre and a MySQL databases.
Every first time that I access the database from Java (after a while), it always fails. I have check Tomcat’s log and found this:

The last packet sent successfully to the server was 85,313,128 milliseconds ago. is
longer than the server configured value of ‘wait_timeout’. You should consider either
expiring and/or testing connection validity before use in your application, increasing
the server configured values for client timeouts, or using the Connector/J connection
property ‘autoReconnect=true’ to avoid this problem.

I have checked this question
but don’t really understand the solution (or if it applies to my case) or why this is happening.

I suppose the problem is that the Postgre/MySQL database was idle for too long, but when I access the database with Java I open a connection and always close it when finished, so I do not understand why the connection should remain open for so long.

Does Anyone have any ideas?

UPDATE:

I am not using C3PO… I connect with:

 Datasource d = context.lookup("....");
 Connection c = d.getConnection();

And disconnect with:

c.close();

And the context for MySQL looks like:

<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="200" maxIdle="15" maxWait="-1" name="jdbc/project" password="...." type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/project" username="..."/>
<ResourceLink global="jdbc/project" name="jdbc/project" type="javax.sql.DataSource"/>
  • 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-23T17:34:41+00:00Added an answer on May 23, 2026 at 5:34 pm

    I’m guessing you’re using a connection pool to get connections to MySQL. The principle of a connection pool is that it opens a bunch of connections, and gives you one of them when you ask for. When you close the connection, the physical connection is not closed, but the connection returns to the pool in order to be used by another request. This allows much better performance because you avoid opening and closing connections endlessly: opening a connection is costly.

    The problem is that is one of the connection stays in the pool without being used for too much time, MySQL considers that it’s not useful to let it open anymore, and closes it.
    To avoid this, you can

    • configure your connection pool to test the connection before giving it to you
    • or increase the wait_timeout on the MySQL server as indicated in the error message
    • or use the connection property autoReconnect=true as indicated in the error message.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons,
I have a Java application that is running perfectly under windows, i go to
We have an issue related to a Java application running under a (rather old)
I have a Java application that launches another java application. The launcher has a
I have a Java application that monitors a folder for incoming XML files. When
I have a Java application that's very String-heavy - it takes a feed of
I have a java application that has Web Services published using Axis. With the
I have a java application that is connected to a view on a remote
I have a web application running under Tomcat. Logging for various features is implemented
I have an application running in cluster mode (two nodes) under tomcat/Linux. Unfortunately I've

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.