带返回值 CallableStatement

String insert = "exec Student_ADD ?,?";
 pstatInsert.setString(1, "0"); 
 pstatInsert.setString(2, "wjboy49"); 
pstatInsert.registerOutParameter(1, java.sql.Types.INTEGER); pstatInsert.execute();
String stuId = pstatInsert.getString(1);
//或者是String stuId = pstatInsert.getString("stuId");

这时stuId 就是存储过程返回的值了。

 

存储过程如下:

create PROCEDURE [dbo].[Student_ADD]
@stuId int output,
@stuName varchar(100),
 AS 
  .......

你可能感兴趣的:(java,sql)