Skip to Main Content

Java and JavaScript in the Database

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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
199 views