1. 程式人生 > >Java中調用存儲過程或函數

Java中調用存儲過程或函數

type str connect () log leave ble rec 多個

//?代表一個參數,多個參數用逗號隔開

CallableStatement cs = connect.prepareCall("{?=call 存儲過程名稱或函數名(?)}");

cs.registerOutParameter(1, Types.VARCHAR);//按參數順序設置參數類型
cs.setString(2,"參數值");//參數賦值
cs.execute();
String result = cs.getString(1);//返回值

cs.close();

1 CallableStatement cs = connect.prepareCall("{?=call f_Leave(?)}");
2 cs.registerOutParameter(1, Types.VARCHAR); 3 cs.setString(2, "參數"); 4 cs.execute(); 5 String result = cs.getString(1);//返回結果 6 cs.close();



Java中調用存儲過程或函數