L
Lex
I have some problem updating multiple records by calling a MS SQL
stored procedure with parameters in java. It seems it locks the records
forever and my application cannot read the table anymore.
Anyone had experience this before?
below is my java code:
CallableStatement cs = null;
try {
// Call a procedure with one IN parameter
cs = con.prepareCall("{call NewUpdateAccounts(?)}");
// Set the value for the IN parameter
cs.setString(1, "1,2,3,4,5,6");
// Execute the stored procedure
cs.executeQuery();
cs.close();
//con.close();
}
catch (SQLException e) {
//sql = sql;
log(e, "ValidateMe.updateAccounts: reading
sp:UpdateAccounts: " + e.getMessage());
}
below is my sp:
ALTER PROC UpdateAccounts
@Active VARCHAR(500)
AS
-- Create a variable @SQLStatement
DECLARE @SQLStatement varchar(500)
SET @SQLStatement = ' UPDATE Registration SET Active =1 WHERE MemberID
IN(' + @Active + ') '
-- Execute the SQL statement
EXEC(@SQLStatement)
stored procedure with parameters in java. It seems it locks the records
forever and my application cannot read the table anymore.
Anyone had experience this before?
below is my java code:
CallableStatement cs = null;
try {
// Call a procedure with one IN parameter
cs = con.prepareCall("{call NewUpdateAccounts(?)}");
// Set the value for the IN parameter
cs.setString(1, "1,2,3,4,5,6");
// Execute the stored procedure
cs.executeQuery();
cs.close();
//con.close();
}
catch (SQLException e) {
//sql = sql;
log(e, "ValidateMe.updateAccounts: reading
sp:UpdateAccounts: " + e.getMessage());
}
below is my sp:
ALTER PROC UpdateAccounts
@Active VARCHAR(500)
AS
-- Create a variable @SQLStatement
DECLARE @SQLStatement varchar(500)
SET @SQLStatement = ' UPDATE Registration SET Active =1 WHERE MemberID
IN(' + @Active + ') '
-- Execute the SQL statement
EXEC(@SQLStatement)