Get ResultSet with CallableStatement after executeBatch ()

I need to call the stored procedure several times and use it for this executeBatch(). Each call should return a table with the results, but I could not access these results. The following code works fine:

callableStatement.setString(1, "foo");
callableStatement.setString(2, "bar");
callableStatement.execute();
resultSet = callableStatement.getResultSet();

But the following code does not work properly:

for (String str : strings) {
    callableStatement.setString(1, str);
    callableStatement.setString(2, "bar");
    callableStatement.addBatch();
}
callableStatement.executeBatch();
resultSet = callableStatement.getResultSet(); // returns null

I already tried calling callableStatement.getUpdateCount()and callableStatement.getMoreResults()before retrieving the ResultSet, but to no avail.

+1
source share
1 answer

#executeBatch. , . //, . #executeBatch , ,

, .

, ResultSet ( , [ ]).

+4

All Articles