Error Too many connections Hibernate + MySQL

2

I have an application in development in Java using Hibernate and PrimeFaces, in the list of items I have the option to do a search for some information in real time using several filters.

However when I run the application and perform some tests I get the following return on 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)
...

Can I clean up searches as I make new ones?

    
asked by anonymous 17.03.2015 / 17:23

2 answers

0

I checked how I communicate and get data via Hibernate in the code by making sure that threads that were no longer useful and were consuming computer memory were being opened. I changed the code so I would not open a thread and leave it open.

    
05.03.2016 / 15:06
1

Good evening, Paulo,

Takes a test, changes the my.cnf file into / etc / mysql /, and modifies the following parameters: max_user_connections = 0 max_connections = 1000

If you do not have access to the server, or you 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, make sure you are using connection management correctly.

link link

    
30.01.2016 / 03:34