//调用存储过程带参
CallableStatement ca = conn.prepareCall("{call Login (?,?)}");
ca.setString(1,username);
ca.setString(2,password);
ca.execute();
//调用存储过程带返回参数的
CallableStatement ca = conn.prepareCall("{call Login (?,?,?)}");
ca.setString(1,username);
ca.setString(2,password);
ca.registerOutParameter(3,java.sql.Types.INTEGER);
ca.execute();
int returnOut = ca.getInt(3);
//调用存储过程带返回值的return
CallableStatement ca = conn.prepareCall("{?=call Login (?,?,?)}");
ca.setString(2,username);
ca.setString(3,password);
ca.registerOutParameter(1,java.sql.Types.INTEGER);
ca.execute();
int returnOut = ca.getInt(1);
//调用存储过程返回两个结果集
CallableStatement ca = conn.prepareCall("{call Login (?,?,?)}");
ca.setString(1,username);
ca.setString(2,password);
ca.execute();
ResultSet rs = ca.getResultSet();
while(rs.next())
{
System.out.println(rs.getInt(1)+rs.getString(2));
}
if(ca.getMoreResults())
{
rs = ca.getResultSet();
while (rs.next()) {
System.out.println(rs.getInt(1) + rs.getString(2));
}
调用存储过程的几种方法
最新推荐文章于 2021-02-26 15:45:53 发布