HttpClient throwing exception org.hibernate.exception.GenericJDBCException?

-3

Is there any reason for the following code to throw this exception? I have a webservice that queries my bank and transforms everything into 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.

    
asked by anonymous 14.03.2014 / 17:45

2 answers

0

Problem solved, it was a session error caused by the client, not the server.

    
14.03.2014 / 20:20
-1

The problem is described in the exception, the maximum number of connections to the bank (20) has been exceeded. You can configure the database and increase that number or use a kind of connection pool where the system maintains an X number of open connections and uses the same connections for different queries. There are many possibilities.

    
14.03.2014 / 18:07