[Java] 呼叫預存程序 (call Stores Procedures)

Stores Procedures

1.無參數

 

cs=conn.prepareCall("{call sp_test1}");
cs.execute();
cs=conn.prepareCall("{call sp_test1(?,?)}");
cs.set String(1,"ABC");
cs.set String(2,"123");
cs.execute();

3.有輸出參數

 cs= conn.prepareCall("{call sp_test1(@N,@O OUTPUT)}"); 
cs.registerOutParameter(1,Types.VARCHAR); 
cs.setString(1,"XXX"); 
cs.execute(); 
String outParam = cs.getString(1);
out.print(outParam);