aspose file tools*
The moose likes JDBC and the fly likes Not able to read ResultSet from as400 stored procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Not able to read ResultSet from as400 stored procedure" Watch "Not able to read ResultSet from as400 stored procedure" New topic
Author

Not able to read ResultSet from as400 stored procedure

Srinivasan Varadharajan
Greenhorn

Joined: Nov 16, 2009
Posts: 2
My stored procedure on AS400 returns a result set to the caller. The 'execute' is successful. (returns true)
But, when I read the result set, there are no records. Please see sample code below:

CallableStatement sqlCall = connection.prepareCall("CALL PROC1(?,?,?)");

// Run an SQL SELECT statement

sqlCall.setInt(1, 1) ;
sqlCall.setInt(2, 5) ;

sqlCall.registerOutParameter(3, java.sql.Types.INTEGER);
System.out.println ("Calling the as400 procedure...");

boolean b = sqlCall.execute();

if(b){
ResultSet rs = sqlCall.getResultSet();

System.out.println ("Retrieving the out parms...");
int total = sqlCall.getInt(3);

while(rs.next())
{
// do something here...
}

} //end if

The value of 'b' is true. getResultSets() also is not null. (Returns a id=CSRS0001 while doing println(rs) )
I am breaking my head over why I am not able to read any records? Any help is appreacited.



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

"SideWinder Bullock", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

A ResultSet with zero records is a perfectly normal thing to encounter.
Srinivasan Varadharajan
Greenhorn

Joined: Nov 16, 2009
Posts: 2
But the stored procedure returns a result set. I am sure the query (in the procedure) returns about 800 records...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Not able to read ResultSet from as400 stored procedure