0

sometimes I need to call a store procedure for n times in a forEach. This works fine but sometimes when n is so large I have problem with connection pool. Particularely I got this exception:

10:34:18,965 ERROR [it.eurobet.easy.service.admin.GroupServiceImpl] (default task-8) Could not get JDBC Connection; nested exception is java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/OracleDS: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/OracleDS

If I increase the number of connection pool, I fix this issue but I don't think this is the better way. I suppose (for this type of operation) I need 1 connection pool for exectue all stored procedures.

Someone can help me?

Thanks

Fabrizio P
  • 241
  • 3
  • 13

1 Answers1

0

You can using Spring jdbctemplate execute method to call the stored procedure.

Code instance:

getJdbcTemplate().execute(new ConnectionCallback() {
  public Object doInConnection(Connection con) throws JMSException {
    DataSource ds = new SingleConnectionDataSource(con);
    MyStoredProcedure sp = new MyStoredProcedure(ds);    
    return null;
  }
});

Refer

Also check here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
DAIRAV
  • 723
  • 1
  • 9
  • 31
  • Hi and thanks for your solution. If I use this code, when I call SimplJdbcCall.execute, does it open and close a new connection or use the same? – Fabrizio P Apr 05 '18 at 10:49