1

I have a multi threaded program which connects to a oracle database.

The first thread executes a "big" query and loads the objects in to a LinkedBlockingQueue. There are around 200,000 objects.

The second thread polls this list, and for each object, it runs 14 other queries, updating the object parameters. Then I connect to another database, one final time, get corresponding object for this current object, create a hybrid object containing these two objects and sends it to third thread.

I am using a single statement and multiple result sets for each one of these 14 queries.

    stat=predefinedobject.getConnection().createStatement();  
    ResultSet rs = null;
    ResultSet rs1 = null;
    ResultSet rs2 = null;
    ResultSet rs3 = null;
          .
          .
    rs=stat.executeQuery(Query1);
    while(rs.next()) {
        object1.setParameter1(rs.getString(5));
    }
    SqlUtils.closeResultSet(rs);

    rs1=stat.executeQuery(Query2);
    while(rs1.next()) {
        object1.setParameter2(rs1.getString(5));
    }
    SqlUtils.closeResultSet(rs1);
           .
           .
           .
    SqlUtils.closeResultSet(rs14);
    SqlUtils.closeResultSet(stat);

I am getting the null pointer exception after some time.

java.lang.NullPointerException
at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:876)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:825)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:845)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1313)
4
  • What Oracle server and driver version? Commented Sep 9, 2014 at 19:32
  • I think we are using Oracle 11g, no idea about the driver version though Commented Sep 9, 2014 at 19:41
  • The error seems to occur inside the driver, which could indicate a bug in the driver; or maybe your SqlUtils.closeResultSet ignores exceptions that might be relevant leading to an inconsistent state inside the driver (which would still be a bug in the driver). I suggest you 1) check the driver version and upgrade to the latest, 2) check if your utility method ignores exceptions and see if any are occurring there. Commented Sep 10, 2014 at 7:15
  • This error could also be due to a sintax error in the query Commented Aug 18, 2017 at 21:59

3 Answers 3

3

Double check your sql query strings , it seems you concatenate the query but missing some space in it.

For example;

String sql="select"+MYCOULUM+" form MYTABLE"

will produce the following string

selectMYCOULUM form MYTABLE

and executing such query will result this error for oracle jdbc driver

Sign up to request clarification or add additional context in comments.

Comments

1

In my case, I've used upper case CALL instead of lower case call to call stored proc.

For example, { ?= CALL proc_name(?) } is giving the same error. Once I change to { ?= call proc_name(?) } it is working

2 Comments

me too, I changed CALL to call and the exception gone.
I also have an out SYS_REFCURSOR as first parameter and the query should be {call MY_SP_NAME(?, :param1, :param2)} . first parameter ? is that ref cursor
0

The javadoc says - By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.

So may be try to create a new Statement object each time you want to query the database

6 Comments

Still I am getting the same Null Pointer Exception.
java.lang.NullPointerException at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:876) at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:825) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049) at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:845) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154) at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1313)
As the error seems to occur inside the driver, I'd sooner attribute it to a bug in the driver.
@MarkRotteveel a similar issue is over here may be some i guess it is some query problem
@SparkOn That still describes a bug in the driver; a JDBC driver should only ever throw SQLException, all others should be considered a driver bug. But agreed: having the actual queries used that cause the exception might be helpful in finding a workaround.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.