Too Many Hibernate+Mysql Connections error

Asked

Viewed 444 times

2

I have an application in development in Java using Hibernate and Primefaces, on the item listing screen I have the option to do a search for some information in real time using multiple filters.

However when running the application and performing some tests I have following return in the output of my development console.

WARN:   SQL Error: 1040, SQLState: 08004
ERROR:   Data source rejected establishment of connection,  message from server: "Too   many connections"
Informações:   javax.el.ELException: /listaProduto.xhtml @45,83 value="#{produtoBean.pesquisa()}": org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
javax.el.ELException: /listaProduto.xhtml @45,83 value="#{produtoBean.pesquisa()}": org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:732)
at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:1002)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:629)
at org.primefaces.component.api.UIData.setRowModel(UIData.java:436)
at org.primefaces.component.api.UIData.setRowIndex(UIData.java:428)
at org.primefaces.component.api.UIData.visitTree(UIData.java:717)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
...

It is possible to clean the research as new?

  • We will need more details: how is your code to open/close Hibernate session? Or is it managed by some framework (Spring, EJB, etc)? This error always occurs or is intermittent?

2 answers

1

Boa noite Paulo,

Do a test, change the file my.cnf within /etc/mysql/, and modify the following parameters: max_user_connections=0 max_connections=1000

If you do not have access to the server, or are using a shared instance, you will need to contact the provider.

If the problem still persists and your case does not fit the above item, check if you are using correctly the management of connections.

https://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html https://commons.apache.org/proper/commons-dbcp/

0


It was verified the way I communicate and obtain the data via Hibernate in the code, by making sure that threads were being opened that were no longer useful and they were consuming computer memory. The code was changed so I didn’t open a thread and leave it open.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.