62,623
社区成员
发帖
与我相关
我的任务
分享
CallableStatement cstmt=null;
public Connection conn = null;
conn = DriverManager.getConnection(url,username,password);
String sql = "{call name(?,?)}"; //name为存储过程名
cstmt = conn.prepareCall(sql);
cstmt.setString(1,"1"); //设置参数1,这里是存储过程的输入参数
cstmt.registerOutParameter(2,Types.INTEGER); //设置参数2类型,这里是输出参数,类型是整型
cstmt.execute();
int i=cstmt.getInt(2); //得到输出的参数,形参和上面设置的输出参数一样
System.out.println(i);