我有这个存储过程:
ALTER PROCEDURE dbo.getRegionsInArea
(
@areaID int,
@ID int OUTPUT,
@name varchar(50) OUTPUT
)
AS
BEGIN
SET NOCOUNT ON
SELECT @ID = [ID], @name = [name] FROM Region
WHERE areaID = @areaID
END
我想从JDBC
.
问题g
如何获取变量输出的所有值,ID
因为name
存储过程会返回它们的许多值。
我试过的
Connection con = Database.getConnection();
String storedProcedure = "{call getRegionsInArea (?,?,?)}";
CallableStatement callableStatement = null;
try {
callableStatement = con.prepareCall(storedProcedure);
callableStatement.setInt(1, getID());
callableStatement.registerOutParameter(2,
java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3,
java.sql.Types.VARCHAR);
callableStatement.execute();
System.out.println("ID = " + callableStatement.getInt(2));
System.out.println("name = "
+ callableStatement.getString(3));
问题
ID
我刚刚收到and的最后一个值name
。
请有任何帮助