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!

ResultSet returns NULL after executing the stored proc.

843854Aug 16 2004 — edited Aug 18 2004
Hi,

We are running WebLogic version 6.0 sp2 with Oracle 8.1.6. as the database.
I am trying to execute a stored procedure using a jdbc call, and then return the results into a resultSet.
The stored proc executes successfully, but the ResultSet returns a NULL !! Why ?
I am implementing the method getResultSet method as specified. Is there some issue with the driver ?
Should i use Oracle JDBC thin driver ?

Any help would be greatly appreciated.
I have attached the java source code. You will see that the source code does a lookup in the JNDI. That JNDI viz: JNDIMit , is configured to make use of weblogic jDriver.

import java.sql.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.io.*;
import javax.naming.*;
import javax.sql.*;
import weblogic.jndi.*;

public class jdriver
{
public static void main (String[] args) throws Exception
{


Connection connection = null;
Statement statement = null;
ResultSet rs = null;

System.out.println("Running program as user: " + System.getProperty("user.name"));

//Get connection to DataSource - which would connect to JDBCPool
//Setup Initial context factory and lookup DataSource in JNDI.
Context ctx = null;
Hashtable ht = new Hashtable();
System.out.println("Setting initial context");
ht.put(ctx.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(ctx.PROVIDER_URL,"t3://localhost:6800");


try {

ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("jDriverJNDI");
java.sql.Connection conn = ds.getConnection();

// Make jdbc call for stored proc.
String sqljdbc = "{call CISADM.BRMTEST(?,?)}";
CallableStatement jdbccall = conn.prepareCall(sqljdbc);

// Register the out parms

jdbccall.registerOutParameter(2, java.sql.Types.VARCHAR);
// Set the input parm value from the command line.
jdbccall.setString(1, args[0]);
jdbccall.execute();

// PROBLEM OCCURS HERE. THE RESULTSET RETURNED IS NULL
rs = jdbccall.getResultSet();
while (rs.next()) {
System.out.println("Value :" + rs.getString(1));
System.out.println("Value :" + rs.getString(2));
System.out.println("Value :" + rs.getString(3));
}
//System.out.println("Value : " + jdbccall.getString(1) + " " + jdbccall.getString(2));


jdbccall.close();
rs.close();
conn.close();

} catch (NamingException e) {
System.out.println("Can't set JNDI context\n" + e);
}
finally {

}

}

}



// RESULT WHEN THE JAVA PROGRAM IS EXECUTED.

Running program as user: cissys
Setting initial context
Exception in thread "main" java.lang.NullPointerException
at jdriver.main(jdriver.java:50)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2004
Added on Aug 16 2004
9 comments
2,273 views