Is there any reason for the following code to throw this exception? I have a webservice
that queries my bank and transforms everything into xml and then sends to another webservice
gets the answer and updates my database, everything works fine until the code executes exactly 20 times, then I get one such exception:
org.hibernate.exception.GenericJDBCException: org.hibernate.exception.SQLStateConverter.handledNonSpecificException (SQLStateConverter.java:126) org.hibernate.exception.SQLStateConverter.convert (SQLStateConverter.java:114) org.hibernate. exception.JDBCExceptionHelper.convert (JDBCExceptionHelper.java:66) org.hibernate.exception.JDBCExceptionHelper.convert (JDBCExceptionHelper.java:52) org.hibernate.jdbc.ConnectionManager.openConnection (ConnectionManager.java:449) org.hibernate.jdbc. ConnectionManager.getConnection (ConnectionManager.java:167) org.hibernate.jdbc.BorrowedConnectionProxy.invoke (BorrowedConnectionProxy.java:74) com.sun.proxy $ Proxy221.prepareStatement (Unknown Source) br.com.store.dao.conexao. connect.PreparedSt (connect.java:54) br.com.store.servlets.webservice.ImportPuedidoXML.validaUsuario (ImportPedidoXML.java:137) br.com.store.servlets.webservice.ImportPedidoXML.doPost (ImportPedidoXML.java:93) br.com.store.servlets.webservice.Im portPuedidoXML.doGet (ImportPedidoXML.java:80) javax.servlet.http.HttpServlet.service (HttpServlet.java:617) javax.servlet.http.HttpServlet.service (HttpServlet.java:717) org.jboss.web.tomcat. filters.ReplyHeaderFilter.doFilter (ReplyHeaderFilter.java:96)
root cause
java.sql.SQLException: Couldn't get connection because we are at maximum connection count (20/20) and there are none available
Here is the code that connects to the client:
try {
HttpClient client = new DefaultHttpClient();
URIBuilder builder = new URIBuilder();
builder.setScheme("http")
.setHost(StoreWS.getHostStatus())
.setPath(StoreWS.getPathStatus())
.setParameter("tx_login", StoreWS.getUsuarioStatus())
.setParameter("tx_senha", StoreWS.getSenhaStatus())
.setParameter("cd_pedido",
String.valueOf(pedido.getCd_pedido()));
URI url = builder.build();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String output;
while ((output = br.readLine()) != null) {
resposta.append(output);
}
br.close();
response.getEntity().getContent().close();
// client.getConnectionManager().shutdown();
} catch (Exception e) {
e.printStackTrace();
} finally {
return resposta.toString();
}
The exception always appears here, does not appear when I update my bank after receiving the response which would make more sense because it is an exception of JDBC
?
I use Spring
, JDBCTemplate
with DataSource
, already tried everything, increase the pool, but always gives the same problem.