简体   繁体   中英

Hibernate+PostgreSQL “Too Many Connections” error

I've app, which use the database in multiple concurrent sessions (over 1000). In Postgres the max connections available is set to 100 by default and i haven't change this.

Hibernate has max connection pool size is 20, but the app seems to be ignored this and throws "Too many connections" error.

So the problem is how to handle over 1000 sessions when the only available is 100? Is there queue or smth like this is possible?

Hibernate has max connection pool size is 20, but the app seems to be ignored this and throws "Too many connections" error.

Double check your use of Hibernate Session Factory:

  • in case your is a web app read this [1]
  • in case your is a standalone app read this [2]

Often the problem is the bad usage of Hibernate Session.

[1] https://developer.jboss.org/wiki/UsingHibernatewithTomcat [2] http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch01.html#tutorial-firstapp-workingpersistence

So the problem is how to handle over 1000 sessions when the only available is 100? Is there queue or smth like this is possible?

100 are the concurrent connection that you can open, over these you can do more than 100 operations: Hibernate just manage the queue for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM