Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error in accessing ResultSet - Descriptor index not valid SQL Exception

843859Jan 13 2006 — edited Jan 14 2006
Hi
I am trying to execute a procedure in java and try to access the result set, but it is giving out Descriptor index not valid SQL Exception.
While printing the first record the error is thrown the code is as follows. Any help would be appreciated. Thanks in Advance.

1 . The Procedure
CREATE PROCEDURE library.fetchssncursor()
RESULT SETS 1 
LANGUAGE SQL
BEGIN

DECLARE c1 CURSOR WITH RETURN FOR 
SELECT * FROM VBPLTC.LTCP_DUMMY;
open c1;
END;
2. Java Class
public class TestFunction2 
{
public void getPassThruReport()
 {
 	Connection objConnection=null;
	ResultSet rs=null;
	CallableStatement callableStatement=null;
 	try
	{
 		List returnList=new ArrayList();
			
		
		DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
		objConnection = DriverManager.getConnection("URL","USERID","PWD");
		callableStatement  = objConnection.prepareCall("{call fetchssncursor() }");
		 System.out.println("Got Connection "+ objConnection.toString());  
		 
		

		   callableStatement.execute();
		   rs = callableStatement.getResultSet();
		   // callableStatement.executeQuery (); i also tried this

		   
		  if(rs!=null)
		   {
		  	

		    while(rs.next())
		   	 {	    	
		    	System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getInt(3)+","+rs.getInt(4));
	   	         }
		   }
		  
	
		}			
	catch(SQLException e)
	{		
		System.out.println("SQLException "+e); 
	}

	catch(Exception e)
	{		
		System.out.println("Exception "+e); 
	}
	finally
	{
		try
		{
			if(rs!=null)	
			rs.close();
			if(objConnection!=null)
			objConnection.close();
			
		}
		 catch (SQLException e) {
            
            
		 }
		
	}
 }
 public static void main(String args[])
  {
  	  	
  	TestFunction2 obj = new TestFunction2();
  	obj.getPassThruReport();
  	
  }
}
3. Output

***************************************


Got Connection S101C3DE
shar,Sharath,123456,1 <------------- records
SQLException java.sql.SQLException: Descriptor index not valid.(1574


****************************************
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2006
Added on Jan 13 2006
1 comment
831 views