存储过程:有参数
调用函数:
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);
本文详细阐述了如何使用SQL语句与存储过程进行数据库操作,包括参数设置、执行存储过程及获取输出结果。

被折叠的 条评论
为什么被折叠?



