运行此程序时出现错误:
1. cs = getCon1().prepareCall("{CALL SaveLabourWageDetails(?,?)}"); 2. cs.setString(1, user.getUserId()); 3. cs.registerOutParameter(2, java.sql.Types.INTEGER); //<--- ERROR at this line 4. cs.execute(); 5. String lastIsertId=cs.getString(2);
存储过程为:
CREATE PROCEDURE `cheque_alert`.`SaveLabourDetailsHead`(IN wage_entered_by VARCHAR(10),OUT LastInsertId INT) BEGIN INSERT INTO `cheque_alert`.`labour_wage_head` ( `wage_entered_by`, `entered_date_time`) VALUES (wage_entered_by, NOW()); SELECT LAST_INSERT_ID() INTO LastInsertId; END$$ DELIMITER ;
请指出此代码中的问题。
您正在调用错误的过程。您有程序SaveLabourDetailsHead,正在打电话
SaveLabourDetailsHead
1. cs = getCon1().prepareCall("{CALL SaveLabourWageDetails(?,?)}"); ↑
改成,
1. cs = getCon1().prepareCall("{CALL SaveLabourDetailsHead(?)}");
设置String参数wage_entered_by。
wage_entered_by