我正在使用以下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級別執行。「。看到我的第一篇文章。 –