I'm trying to get the result of my Result Set where I register my 2nd parameter as INTEGER
. From what I read I should get the object first before retrieving it using Result Set.
Code
try (Connection myConn = DBUtil.connect();
CallableStatement myFirstCs = myConn.prepareCall("{call getSECTION_NAME(?,?)}"))
{
myFirstCs.setString(1, searchSection);
myFirstCs.registerOutParameter(2, Types.INTEGER);
myFirstCs.executeUpdate();
String name = null;
System.out.println(myFirstCs.getObject(2));
ResultSet myRs = null;
myRs = (java.sql.ResultSet)myFirstCs.getObject(2);
while (myRs.next()) // Retrieve result set rows
{
name=myRs.getString(1);
System.out.print("Section Name: "+name);
}
myRs.close();
Is this the proper way retrieving Result Set? I try this method using try with resource. I missed something here ResultSet myRs = myFirstCs.getObject(2, type)
don't know what will I put in my 2nd parameter?
Sample Only
try (ResultSet myRs = myFirstCs.getObject(2, type))//What should I put here?
{
while (myRs.next())
{
name = myRs.getString(1);
System.out.print("Section Name: "+name);
}//end of while
}
Feel free to comment. Any help would appreciate. Thank you.