java调用存储过程和函数
原创
©著作权归作者所有:来自51CTO博客作者pyzheng的原创作品,请联系作者获取转载授权,否则将追究法律责任
存储过程:有参数
String rSet=null;
CallableStatement cStatement=null;
try {
cStatement=connection.prepareCall("{Call sellTicketPROC(?,?,?,?,?,?,?)}");
cStatement.setString(1, lineID);
cStatement.setString(2, beginStation);
cStatement.setString(3, endStation);
cStatement.setString(4, date);
cStatement.setString(5, TrainNum);
cStatement.setString(6, seatTyle);
cStatement.registerOutParameter(7,Types.VARCHAR);
cStatement.execute();
rs=cStatement.getString(7);//得到输出结果
调用函数:
sql="{?=call function_test(?,?)}";
st.registerOutParameter(1, Types.VARCHAR);
cStatement.setString(2, lineID);
cStatement.setString(3, beginStation);