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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:56:05+00:00 2026-05-11T13:56:05+00:00

We host a service (servlet running on jboss), which receives something like 5-6 requests

  • 0

We host a service (servlet running on jboss), which receives something like 5-6 requests per second. Every request needs to connect to mysql through hibernate. Most of our requests do selects, with an insert/update every 5th/6th request. The hibernate mysql connection gets timed out after mysql connection time out period (8 hours). Even after having a request pinging our service, every hour, the mysql connection sometimes gets randomly disconnected after a day or so. We want hibernate to reconnect in case the connection is disconnected due to any reason, and maintain the number of connections we want it to.

We tried C3P0, with the following configuration:

<property name=c3p0.acquire_increment>1</property> <property name=c3p0.idle_test_period>3600</property>  <property name=c3p0.max_statements>0</property>  <property name=c3p0.min_size>1</property>  <property name=c3p0.timeout>3605</property>  <property name=hibernate.c3p0.preferredTestQuery>select 1;</property> 

Hibernate connection_pool size was set to 1.

This made the timeout/disconnect problem go away. But we started facing another problem. Long waits. Normally the request serve time for us is 2-3ms for select and 40-50ms for insert/update. But, after using the above C3P0 configuration, we saw that every request completing after an update was taking more than a minute and sometimes even 4-5 minutes! From our logs, it seemed that randomly a select request would get stuck and will be able to complete only after an update request was received and served.

Above problem goes away if we remove the C3P0 config. Can somebody suggest what we might be doing wrong?

Here is the complete hibernate config for reference:

<?xml version='1.0' encoding='utf-8' ?>  <!DOCTYPE hibernate-configuration PUBLIC           '-//Hibernate/Hibernate Configuration DTD 3.0//EN'           'http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd'>  <hibernate-configuration>     <session-factory>          <property name='connection.driver_class'>com.mysql.jdbc.Driver</property>         <property name='connection.url'>jdbc:mysql://xxx.xxx.xxx</property>         <property name='connection.username'>xxx</property>         <property name='connection.password'>xxx</property>         <property name='connection.pool_size'>1</property>          <property name='dialect'>org.hibernate.dialect.MySQLDialect</property>         <property name='current_session_context_class'>thread</property>         <property name='hibernate.cache.use_query_cache'>false</property>         <property name='hibernate.cache.use_second_level_cache'>false</property>         <property name='show_sql'>true</property>          <!-- Transaction isolation 2 = READ_COMMITTED -->         <property name='connection.isolation'>2</property>         <property name='connection.autocommit'>true</property>          <!-- configuration pool via c3p0-->         <property name='c3p0.acquire_increment'>1</property>         <property name='c3p0.idle_test_period'>3600</property> <!-- seconds -->         <property name='c3p0.max_size'>1</property>         <property name='c3p0.max_statements'>0</property>         <property name='c3p0.min_size'>1</property>         <property name='c3p0.timeout'>3605</property> <!-- seconds -->         <property name='hibernate.c3p0.preferredTestQuery'>select 1;</property>      </session-factory> </hibernate-configuration> 
  • 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. 2026-05-11T13:56:06+00:00Added an answer on May 11, 2026 at 1:56 pm

    I’d recommend abandoning C3P0 and using the JNDI naming service and connection pooling that JBOSS provides.

    Be sure that you are closing connections properly and returning them to the pool. Connect, query, close, all in the narrowest scope possible. No connection should be hanging around for eight hours.

    Some more links might be pertinent: http://www.hibernate.org/117.html and http://www.informit.com/articles/article.aspx?p=353736&seqNum=4 regarding Hibernate and closing connections, and this MySQL bug that cites problems with MySQL, Hibernate, and connections: http://bugs.mysql.com/bug.php?id=10917

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

Sidebar

Ask A Question

Stats

  • Questions 83k
  • Answers 83k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I was looking for a snippet of code that would… May 11, 2026 at 4:54 pm
  • Editorial Team
    Editorial Team added an answer You cannot flush the input stream. You will be invoking… May 11, 2026 at 4:54 pm
  • Editorial Team
    Editorial Team added an answer Those instructions do work - you have to insert the… May 11, 2026 at 4:54 pm

Related Questions

We use Tomcat to host our WAR based applications. We are servlet container compliant
We host a WCF webservice on Windows Server 2003. This server only has 2
We are going to be selling a service that will be hosted by us,
I need to generate a WCF proxy for a service exposed by our client.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.