I will start by giving you my table content
This is my stored procedure:
ALTER PROCEDURE dbo.getFoodsForOrder
(
@orderID INT,
@ID INT OUTPUT,
@food_restaurantID INT OUTPUT,
@count INT OUTPUT,
@description VARCHAR(200) OUTPUT
)
AS
SET NOCOUNT ON
BEGIN
SELECT [ID],
[food_restaurantID],
[count],
[description]
FROM Order_Food
WHERE orderID = @orderID
END
My Problem
when I call the stored procedure from JDBC like this
Connection con = Database.getConnection();
CallableStatement callableStatement = null;
try {
callableStatement = con
.prepareCall("{call getFoodsForOrder(?,?,?,?,?)}");
callableStatement.setInt(1, getID());
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(4, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
System.out.println("ID = " + getID());
boolean haveResult = callableStatement.execute();
while (haveResult) {
System.out.println("here I am");
haveResult = callableStatement.getMoreResults();
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (callableStatement != null)
callableStatement.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
it just print here I am
once, just once, even If (like the picture said) I have more than 15 rows are ture.
you problem will ask me if I am sure about the getID()
method, Yes I am sure and even when I replace it with explicit 10 , the result doesn't change.
Something might help
when I call that stored procedure from my Visual studio , I got 17 results like this: