-1
我已經創建了用於更新查詢的MySQL存儲過程。我怎麼可以將參數值傳遞給MySql存儲過程
delimiter //
create procedure studentrcs(sname varchar(20),smark1 int(3),smark2 int(3),stotal int(10),inout Regno int(6))
begin
UPDATE studentrecords set student_name=sname,mark1=smark1,mark2=smark2,total=stotal where Reg_no=Regno;
end;//
之後,通過調用語句我怎麼能傳遞價值(在運行時)爲參數的
CallableStatement calstat=null;
calstat=conn.prepareCall("{call studentrcs(?,?,?,?,?)}"); // **how i can pass the value here(at run time).**
//System.out.println("Update");
calstat.setString(1,tname.getText());
calstat.setString(2, treg.getText());
calstat.setString(3, tmark1.getText());
calstat.setString(4, tmark2.getText());
calstat.setString(5, ttotal.getText());
calstat.executeUpdate();
爲什麼你沒有給出正確答案的要點? – YumYumYum 2011-12-27 14:33:03