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

  • SEARCH
  • Home
  • 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 6804639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:29:28+00:00 2026-05-26T19:29:28+00:00

I have some jsp pages that connect to a mysql database and I intermittently

  • 0

I have some jsp pages that connect to a mysql database and I intermittently get the following error message:

“The last packet successfully received from the server was 36,727,995 milliseconds ago. The last packet sent successfully to the server was 36,733,072 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”

The occurrence pattern is pretty random but it tends to happen most frequently after there has not been much activity on the website, like first thing in the morning.

I found this thread on stackoverflow that mentions the same error:
Tomcat6 can't connect to MySql (The driver has not received any packets from the server)

and the final resolution was to add this line:

permission java.net.SocketPermission "127.0.0.1:3306", "connect";

to

$TOMCAT-CONFIG/policy.d/04webapps.policy

I’m running tomcat 7 on centOS 5.5 and I don’t see a policy.d directory nor a 04webapps.policy file anywhere. Do I need to manually create both of these or is there another way I should be resolving this issue?

Update:
Here’s an example of how I query the database in one of my jsp files:

DBFunctions dbf = null;
boolean bException = false;
ArrayList<String[]> arrayListRows1 = new ArrayList<String[]>();
try
{
    dbf = new DBFunctions();
    dbf.db_run_query(query2);
    while (dbf.rs.next()) {
        String [] tmp = new String[6];

        tmp[0] = dbf.rs.getString("fact_data.entity_id");
        tmp[1] = dbf.rs.getString("date_begin");
        tmp[2] = dbf.rs.getString("value");
        tmp[3] = dbf.rs.getString("ticker");
        tmp[4] = dbf.rs.getString("full_name");
        tmp[5] = dbf.rs.getString("name");






        arrayListRows1.add(tmp);

    }
}
catch (SQLException sqle)
{

    out.println(PopulateSpreadsheet.createGoogleError(strReqId,"sql_exception",sqle.getMessage(),"PF ERROR CODE 2eh2-1"));
    bException = true;
}
finally
{
    if (dbf !=null) dbf.closeConnection();
    if (bException == true)
        return;
}

DBFunctions.java sits under the src/ directory of the web application, so it’s not technically a jsp page that is directly querying the database.

I will go back and check one more time, but I tried to code all my database queries the same way with the connection being closed immediately after being done with the ResultSet.

Any recommendations on how best to do an inventory on the connection pool to periodically check the state of the connections?

Update: I’m still having issues with this error. I appreciate the suggestions on moving the bulk of my programming logic out of my jsp pages and into a servlet/library, but I don’t think that will fix this particular issue.

Other people have reported seeing this issue and it’s because mysql is timing out connections in the tomcat jdbc connection pool. It’s odd to me that the tomcat connection pool doesn’t employ some kind of keep alive to avoid this issue. I would think that would be a part of every connection pool design.

  • 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-26T19:29:29+00:00Added an answer on May 26, 2026 at 7:29 pm

    I was able to fix the problem by adding the following properties to context.xml:

    testWhileIdle="true"
    testOnBorrow="true"
    testOnReturn="false"
    validationQuery="SELECT 1"
    validationInterval="30000"
    

    These settings result in a connection being tested when it is pulled from the pool.

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

Sidebar

Related Questions

I have an MySQL database which contains some data,it interacts with JSP pages,the thing
I'm running tomcat and have some jsp pages that display a subset of a
I have several JSP files that are included into other JSP pages. Some of
I have a Tomcat 6.0.24 server running. I'm using to run some JSP pages.
i am new in JSP,i have some problem with the following code : <%@
I have a Joomla (nginx + mysql) site running as UI and some JSP
I have a jsp that contains a table with some information from db. I
I have a page in JSP that list some file that could be downloaded
I have a Spring MVC app that uses JSP to render pages. Spring has
I have a .jsp that contains an IFrame with a page that has some

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.