Skip to Main Content

Java and JavaScript in the Database

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

oracle fuction called from java not getting data from resultset

user13055307Dec 7 2023 — edited Dec 7 2023

ResultSet rs = null;
CallableStatement stmt = null;
List<TestObj> objList= new ArrayList<TestObj>();
try
{
stmt = con.prepareCall( "{? = call TEST_FUNCTION(?,?) }");
stmt.registerOutParameter( 1, Types.VARCHAR );
stmt.setString( 2, "A");
stmt.setString( 3, "B");
stmt.execute();
rs = stmt.getResultSet();
while( rs.next() )
{
TestObj obj= new TestObj ();
obj.setA( rs.getString( "TEST1" ) );
obj.setB( rs.getString( "TEST2" ) );
obj.setC( rs.getString( "TEST3" ) );
obj.setD( rs.getString( "TEST4" ) );
objList.add( obj);
}
}
catch( SQLException e )
{
e.printStackTrace();
}
finally
{
rs.close();
stmt.close();
}

    When run, it gives me a null point exception at 'rs.next()'. Can anyone please tell me how to access the return values from the function.

Note : Passing values to the function and executing the query works fine without any exceptions ( stmt.execute() run without any exceptions )

Comments
Post Details
Added on Dec 7 2023
4 comments
72 views