Solved

c3p0 mysql hibernate configuration

Posted on 2013-05-18
10
174 Views
Last Modified: 2015-05-07
It creates 225 connections. so my tomcat serves for 225 requests and after that those connections goes to sleep mode in mysql. So further requests to tomcat are not responded. Please let me know what changes to be done to overcome this. Because this is currently in production.

Hibernate configuration

                <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
                <property name="hibernate.c3p0.min_size">5</property>
                <property name="hibernate.c3p0.max_size">225</property>

Open in new window

0
Comment
Question by:Ashok9
10 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 39180902
You can change the value from 225 to a higher number.
0
 
LVL 5

Author Comment

by:Ashok9
ID: 39181166
Ideally it should reuse the connections. But why its not using existing connections? Also all the connections are sleeping...?
0
 
LVL 23

Expert Comment

by:nemws1
ID: 39182683
Have you set max_statements? (I'm just guessing here)

  <property name="hibernate.c3p0.max_statements">50</property>
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 5

Author Comment

by:Ashok9
ID: 39186255
what does max_statements do? Does it stop using connection after the max_statements?
0
 
LVL 5

Author Comment

by:Ashok9
ID: 39186256
I tried it with the value of 10. but it was of no use it again makes connections to sleep mode.
0
 
LVL 1

Expert Comment

by:dcpetersonp
ID: 39192075
0
 
LVL 2

Accepted Solution

by:
c_kedar earned 500 total points
ID: 39854292
Most probably, the transaction is not being closed in code. So on every request a connection is being checked out from the pool and is not being returned back to the pool.

Ensure call to transaction.commit() or transaction.rollback() is executed at the end of processing.

If you are using getSessionFactory().openSession() instead of getCurrentSession() then also ensure that session is closed with call to session.close().
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now