Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-04-19 : 10:27:47
|
Jun writes "I create an application role in my database and assign some permission to it. My application role in database is TestAppR, and passward is testapppassward.Then I try to activate this application role in my java application. I got the following error message:com.microsoft.sqlserver.jdbc.SQLServerException: Application roles can only be activated at the ad hoc level.Here is my code. I run this code in WebSphere web container.Any one know how to make a change to this code in order to make it work. Thanke you so much for any help.Statement mssqlstmt = null;Connection mssqlconn = null;try { InitialContext context = new InitialContext(System.getProperties()); //this is SQL server DataSource ds = (DataSource) context.lookup("jdbc/decaDataSource"); mssqlconn = ds.getConnection(); } catch (NamingException ne) { ne.printStackTrace(); } catch (SQLException se) { se.printStackTrace(); } try { //try to activate application role CallableStatement cs; //Call a procedure with two IN parameter cs = mssqlconn.prepareCall("{call sp_setapprole(?,?)}"); cs.setString(1, "TestAppR"); cs.setString(2, "testapppassward"); cs.execute(); cs.close(); }catch (SQLException se) { se.printStackTrace(); }" |
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-04-19 : 22:10:48
|
i only see this error when i try to execute set_approle inside an sproci don't have any dev tools to test this out so try to execute instead of call... exec sp_setapprole TestAppR,'testapppassward'also make sure you're connected before executing the spHTH--------------------keeping it simple... |
 |
|
|
|
|