gstackoverflow gstackoverflow - 26 days ago 7
Java Question

Synchrounous execution of stored procedure

I have the following code:

connection = makeConnection();
CallableStatement callableStatement = connection.prepareCall("{call dbo.delete_orders(?) }");
callableStatement.setString(1, userName);
callableStatement.execute();
callableStatement.close();


Please help me to understand how I can guarantee that after last row execution stored procedure execution will be finished or it executes asynchronously.

Answer

JDBC does not support asynchronous executions.

But on the other hand JDBC also doesn't specify that calling (some of its methods like execute()) is blocking. That means that you may get (first) results from the database while it is still executing the query in background.

But this depends on the implementation of the JDBC driver and the Database itself.