I'm using the following JDBC driver (the one from Microsoft): http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx.
I want to retrieve the OUTPUT parameter (@cookie) of the stored procedure sp_setapprole
. I can call the procedure fine like this, but I can't figure out how to retrieve the OUTPUT parameter.
statement = connection.createStatement();
statement.execute("EXEC sp_setapprole '" + applicationRoleName + "', '" + applicationRolePassword + "'");
I tried with a PreparedStatement and a CallableStatement and I always get the following exception: Stored procedure 'sys.sp_setapprole' can only be executed at the ad hoc level.
. I found this post: https://stackoverflow.com/a/6944693/1362049, but I don't like the solution (use another JDBC driver).
So my question: how to get OUTPUT parameter from stored procedure sp_setapprole
in SQLServer using a Statement
.