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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:46:57+00:00 2026-05-19T13:46:57+00:00

I have a problem with Hibernate (3.6.0.-Final) in my Java EE application using MySQL

  • 0

I have a problem with Hibernate (3.6.0.-Final) in my Java EE application using MySQL and the MySQL Connector/J (official JDBC driver for MySQL).

In my hibernate.cfg.xml, I have these lines of code:

<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost/mydbtest</property>
        <property name="connection.username">root</property>
        <property name="connection.password">mypassword</property>
        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">20</property>
        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <!-- Enable Hibernate's automatic session context management, in this case 
             the session will be close after each transaction! -->
        <property name="current_session_context_class">thread</property>
        <!-- Disable the second-level cache -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
        <!-- auto create tables -->
        <property name="hbm2ddl.auto">none</property>
        ...
    </session-factory>
</hibernate-configuration>

I changed the value of the property connection.pool_size from 1 to 20. I did this because someone was telling me (and I had these problems), that the data was not loaded and an error was thrown with connection pool size. Also,

So I changed the value to 20. but now I get this error:

Hibernate: select ...
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 08S01
ERROR: org.hibernate.util.JDBCExceptionReporter - 
       The last packet successfully received from the server was 61.428.729 
       milliseconds ago.  The last packet sent successfully to the server was 
       61.428. 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.

So what should I do of these possible solutions? What’s the best way to solve these JDBC connection issues? I read sth about c3p0, but I am new to connection pools. I do not understand the problem: I have a connection pool of 20. So why does it fail? Why throwing an exception and not open a new one?

Thank you a lot in advance & Best Regards.

— Update —

<property name=“hibernate.c3p0.acquire_increment”>3</property>
<property name=“hibernate.c3p0.idle_test_period”>14400</property>
<property name=“hibernate.c3p0.timeout”>25200</property>
<property name=“hibernate.c3p0.max_size”>15</property>
<property name=“hibernate.c3p0.min_size”>3</property>
<property name=“hibernate.c3p0.max_statements”>0</property>
<property name=“hibernate.c3p0.preferredTestQuery”>select 1;</property>

— Update 2 —

/etc/my.cnf file:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
  • 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-19T13:46:58+00:00Added an answer on May 19, 2026 at 1:46 pm

    This usually happens after some time of inactivity, and MySQL closed the connection in the server side. But the connection in the client side (your application) is still available, so, it ends up being stale.

    By using a connection pooling mechanism, it gets in charge of opening/closing the connections when needed, avoiding this kind of problem. One solution, as the error message states, is to use the JDBC option autoReconnect=true in the URL. The other is to configure your connection pooling mechanism to open/test the connection before delivering to your application.

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

Sidebar

Related Questions

I have a problem with changing my spring/hibernate application from MySql to SQL Server.
I have a problem using the Java search function in Eclipse on a particular
I have a problem with a little .Net web application which uses the Amazon
I have a little problem with Java (being a C++ programmer). I have 2
I'm using Hibernate 3.5.2-FINAL with annotations to specify my persistence mappings. I'm struggling with
i am coming back because i still have problem using JodaTime. After the previous
I have a hibernate project, which uses JPA. my persistence.xml contents is as follows:
I have a problem getting my change(s) to data object retrieved using NHibernate to
I am porting an application for KodoJDO to Hibernate. I have a query that
i am a hibernate-beginner and have a problem when trying to join 2 tables

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.