I'm trying to create a Login and drop it using using Microsoft JDBC Driver.
CREATE LOGIN ? WITH PASSWORD = 'password'
and
DROP LOGIN ?
But I'm getting following exception in both cases.
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:332)
at org.wso2.carbon.rssmanager.core.internal.manager.MSSQLRSSManager.attachUserToDatabase(MSSQLRSSManager.java:512)
... 57 more
I found similar questions in SO, but couldn't find an exact solution.
Please advice.
Thanks, Bhathiya
[update]
Here is my code snippet.
String sql = "CREATE LOGIN ? WITH PASSWORD = 'abc'";
stmt = conn.prepareStatement(sql);
stmt.setString(1, qualifiedUsername);
stmt.execute();