I have created a Stored Procedure in SQL with more than one SELECT statement and when I CALL the Procedure (using JDBC) in my Java app the program is able to fetch and print columns ONLY from the first SELECT statement. However when I CALL the Procedure from my SQL DB I can see every SELECT statement of my Procedure. Is there any way that I can print the columns of every SELECT statement I have created in my Procedure using JDBC?
I am using the "Callable Statement" to get the connection and "Result Set" so as to print the columns I want.
This is the JAVA code I have
public Something something(int jobID){
openConnection();
Something something = new Something();
String query = "{CALL evaluation(" + jobID + ")}";
ResultSet resultSet;
try {
CallableStatement callableStatement = getConnection().prepareCall(query);
System.out.println(jobID);
callableStatement.addBatch(query);
callableStatement.executeBatch();
resultSet = callableStatement.executeQuery(query);
while(resultSet.next()){
System.out.println(resultSet.getString("message"));
// I can see this column that comes from the first SELECT statement in my Procedure.
System.out.println(resultSet.getInt("per_sc"));
// But I can not see any other column from any other SELECT statement, like this one (or any other one).
}
} catch (SQLException ex) {
Logger.getLogger(ICRUDImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return something;
}
ERROR message: java.sql.SQLException: Column 'per_sc' not found.
Although, 'per_sc' is the name of the second column of my second select statement inside my Procedure.