java调用存储过程的方式
作者:互联网
1、问号是入参和出参,出参要指定类型
CallableStatement pstmt = conn.prepareCall("{call dbo.UP_CodeUp_***(?,?,?,?,?)}");
pstmt.setString(1, "");
pstmt.setString(2, "");
pstmt.setString(3, "");
pstmt.setInt(4, "");
pstmt.registerOutParameter(5, Types.VARCHAR);
pstmt.execute();
retMessage = pstmt.getString(5);
pstmt.close();
conn.close();
2、这个出参的写法和第一个有区别,之前用地一种写法能拿到出参,现在用第二种能拿到,但是不知道为什么??
CallableStatement pstmt = conn.prepareCall("{call dbo.UP_Tools_***(?,?,?)}");
// pstmt.setInt(1, 0);
pstmt.setInt(1, Integer.parseInt(orderId));
pstmt.setString(2, userNo);
pstmt.registerOutParameter(3, Types.VARCHAR, retMessage);
pstmt.execute();
pstmt.close();
标签:存储,调用,java,dbo,setString,setInt,close,conn,pstmt 来源: https://www.cnblogs.com/welearn/p/11956867.html