我正在使用以下JDBC驱动程序(来自Microsoft的一个):http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx。如何在SQLServer中获取存储过程sp_setapprole的OUTPUT参数
我想检索存储过程sp_setapprole
的OUTPUT参数(@cookie)。我可以像这样调用过程,但我无法弄清楚如何检索OUTPUT参数。
statement = connection.createStatement();
statement.execute("EXEC sp_setapprole '" + applicationRoleName + "', '" + applicationRolePassword + "'");
我试图用一个PreparedStatement和一个CallableStatement,我总是得到以下异常:Stored procedure 'sys.sp_setapprole' can only be executed at the ad hoc level.
。我发现这篇文章:https://stackoverflow.com/a/6944693/1362049,但我不喜欢解决方案(使用另一个JDBC驱动程序)。
所以我的问题:如何使用Statement
从SQLServer中的存储过程sp_setapprole
获取OUTPUT参数。
我不能使用CallableStatement(或PreparedStatement),因为我得到的错误'存储过程'sys.sp_setapprole'只能在ad hoc级别执行。“。看到我的第一篇文章。 –