我已经写了registerOutParameter,怎末还会出现找不到输出参数的异常?
存储过程如下:
CREATE Procedure CMRC_CustomerAdd
(
@FullName nvarchar(50),
@Email nvarchar(50),
@Password nvarchar(50),
@CustomerID int OUTPUT
)
AS
INSERT INTO CMRC_Customers
(
FullName,
EmailAddress,
Password
)
VALUES
(
@FullName,
@Email,
@Password
)
SELECT
@CustomerID = @@Identity
部分语句如下:
cs= c.prepareCall("{?=call CMRC_CustomerAdd(?,?,?)}");
cs.setString(2,fullName);
cs.setString(3,emailAddress);
cs.setString(4,password);
cs.registerOutParameter(1,Types.INTEGER);
cs.execute();
测试程序如下:
public class test {
public static void main(String[] args) {
JdbcCustomerOperations j=new JdbcCustomerOperations();
j.AddCustomer("a","a","a");
}
}
错误提示如下:
SQLException:过程 'CMRC_CustomerAdd' 需要参数 '@CustomerID',但未提供该参数。