Changing MS SQL password using JDBC and stored procedure

Hi, I'm trynig to write a method that changes a user's password in MS SQL Server. I understand that the stored procedure to call is sp_password. The following code returns a JDBC error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).

Any help would be appreciated.

CallableStatement cs = con.prepareCall("{ call sp_password(?,?,?) }");
cs.setString(0,oldPassword);
cs.setString(1,newPassword);
cs.setString(2,userName);
cs.execute();
LVL 1
matthew_yorkAsked:
Who is Participating?
 
mmuruganandamConnect With a Mentor Commented:
setString should start from 1 not from 0.

Regards,
Muruga
0
 
matthew_yorkAuthor Commented:
Thanks, that got over that problem but now i get a message:

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1: Incorrect syntax near '{

I'm sure this must be something simple. Thanks in advance.
0
 
mmuruganandamCommented:
this could be a problem with your stored procedure.

check your "sp_password" procedure.  compile it for errors.
0
 
matthew_yorkAuthor Commented:
thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.