Reputation:
I need to execute this SQL code:
exec procedure(param, param, param, param)
select * from bla_bla_table;
commit;
And get a ResultList from this query.
I tried to do it like this:
CallableStatement stmt = connection.prepareCall("{call procedure(param,param,param,param)}");
stmt.execute();
How can I insert sql statement select * from bla_bla_table;
here before commit
to get the ResultSet. I tried a lot of ways to do that... but nothing helps.
Upvotes: 1
Views: 3140
Reputation: 3942
Add this code after the execution of your code.
PreparedStatement prep = connection.prepareStatement(string);
ResultSet rs = prep.executeQuery();
// now iterate the resultset.
Before everything you should make sure that you run a transaction by setting the autocommit option of the connection to false.
connection.setAutoCommit(false);
Upvotes: 1
Reputation: 21883
Did you try this?
connection.setAutoCommit(false); // Disable Auto Commit
CallableStatement stmt = connection.prepareCall("{call procedure(param,param,param,param)}");
stmt.execute();
Statement stmt2 = connection.createStatement();
ResultSet rs = stmt2.executeQuery("select * from bla_bla_table"); // Result set for Query
connection.commit();
Upvotes: 3