Reputation: 9842
I am using java to access mssql 2012 DB
I have a stored procedure "procX" with takes only 1, (say named as @p1) in parameter and returns a single result set. It works fine unless I try to read the return value before I get the result set. Code is below. If I remove "//" and get return value, I get null
as the result.
cs = con.prepareCall("{? = call procX(?)}");
cs.registerOutParameter(1, Types.INTEGER);
cs.setInt("p1", 1);
cs.execute();
//cs.getInt(1);
rs = cs.getResultSet();
And even if I read the return value after I get the resultset, this closes the result set.
Is there a way to read return value without making it impossible to get the resultset?
And as far as I can see this situation is not restricted for return value and occurs for any other output parameters, too.
Upvotes: 1
Views: 3510
Reputation: 9842
Looks like you have to get resultset(s) before reading any of the output parameters.
You can get the detail from https://stackoverflow.com/a/5576442/1519458
Upvotes: 1
Reputation: 5399
It is interesting,
java.util.logging.Logger
for logging before/after executing each
operations.getValue
method which called from getInt
method.Upvotes: 0