• Register
0 votes

Problem :

I am using the Hibernate for a first time for my project and I am very new to Hibernate. I think I have followed all the instructions written in some tutorials but still I keep getting the below Exception that is in my title:

Exception in thread "main" org.hibernate.HibernateException: The internal connection pool has reached its maximum size and no connection is currently available!

What I want to do is simply storing the object into the MySql Database that I have already created.

When I run it I always get above exception and I have no idea why. Maybe I should just change a connection.pool_size property, but if I do so it guesses that I only will get more errors. Can anyone help me?

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :


Please do below changes in your HibernateUtil:

public static Session getHibernateSession() {

    final SessionFactory sf = new Configuration()

    // factory = new Configuration().configure().buildSessionFactory();
    final Session session = sf.openSession();
    return session;

And instead of using the SessionFactory use the Session:

final Session session = HibernateUtil.getHibernateSession();

And after that use the below code:

Transaction tx = session.beginTransaction();
 // all your methods

Hope this helps you in resolving your issue.

And you can actually remove that connection pool property from your hbm if you do not need it.

9 7 4
38,600 points

Related questions

0 votes
1 answer 12 views
Problem: I need help in solving this problem: The internal connection pool has reached its maximum size and no connection is currently available!
asked Mar 14 Wafa Abu Yousef 6.1k points
1 vote
1 answer 328 views
Problem : I am very new to SQL Queries. Recently I have joined new team and I am given below task Find the country that has all the vowels and no spaces in its name? I have written below query SELECT country FROM world WHERE country LIKE '%u'       and country LIKE ... of time in writing the correct query but still unable to do it. So I am looking for sql experts help in fixing my above query.
asked Apr 17, 2020 stewart 4k points
0 votes
1 answer 7 views
Problem: the database returned no natively generated identity value.
asked Feb 22 Dan phillip 4.8k points
1 vote
1 answer 8 views
Problem: Do not have any idea that why I get this? No dialect mapping for jdbc type 1111.
asked Mar 23 PkGuy 13.1k points
0 votes
1 answer 1 view
1 view
Problem: Please assist me in resolving this issue: no buffer space available maximum connections reached
asked Apr 8 tuhin1 48.9k points
0 votes
1 answer 9 views
Problem: How to solve this sql exception?? Please someone help me ...
asked Mar 11 Ifra 24.4k points
0 votes
1 answer 261 views
Problem : I am getting bellow error java.sql.sqlexception lock wait timeout exceeded try restarting transaction I am using Java Struts 2.1 Hibernate configuration. DB Used is MYSQL. Anyone know how to solve it..??
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 20 views
0 votes
1 answer 124 views
0 votes
0 answers 11 views
Problem: Please solve my issue .. i am stuck with this..
asked Mar 5 Ifra 24.4k points