This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 63053
    
  69

"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
Sheriff

Joined: Oct 14, 2005
Posts: 19693
    
  10

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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to read ResultSet from as400 stored procedure
 
jQuery in Action, 3rd edition