Current Position:Home > Intermittent NullPointerException while calling connection.prepareStatement("insert into mytable (myuid, foo) values (SEQ_M_MSG_UID.nextval,?)");

Intermittent NullPointerException while calling connection.prepareStatement("insert into mytable (myuid, foo) values (SEQ_M_MSG_UID.nextval,?)");

Update:11-30Source: network consolidation
Advertisement
Hello,
I am intermittently getting a nullpointer exception while parsing a
query to make a preparedStatement. I am using WebLogic5.1 sp9.
Oracle 817. Java 1.3.1 The code is very simple (although the
setTypeMap(getTypeMap) stuff is there for ugly historical reasons, it
has been included for completeness). Any insight into this problem
would be greatly appreciated.
My only current theory is that it is related to the nextval being
passed in the string to the prepareStatement.
The exception only happens 1 in 2000 calls. This code usually
succeeds. The code is executing in the context of a stateless session
bean. There may be upto 200 client threads calling this method
concurrently from various systems.
...dAmOn
CODE:
final String lQuery = "insert into SB_MESSAGE (M_MSG_UID,
M_MSG_GUID, M_REQUESTOR_GUID, M_MSG_GROUP, M_MSG_REQ_GUID,
M_DEVICE_UID, M_ACCT_UID, M_TASK_ID, M_COMPLETION_STATUS,
M_LAST_STATE, M_FILTER_NAME, M_FINAL_ATTEMPT, M_START_TIME,
M_COMPLETED_TIME, M_TLM_DT)
values(SEQ_M_MSG_UID.nextval,?,?,?,?,?,?,?,?,?,?,'F',?,?,?) ";
PreparedStatement lPs = null;
Driver driver =
(Driver)Class.forName("weblogic.jdbc20.jts.Driver").newInstance();
Connection connection =
driver.connect("jdbc20:weblogic:jts:myPool", null);
connection.setTypeMap(connection.getTypeMap());
// ** This line leads to the stack trace following the line **
lPs = connection.prepareStatement(lQuery);
Stack Trace:
java.sql.SQLException: java.lang.NullPointerException
at oracle.jdbc.driver.OracleConnection.nativeSQL(OracleConnection.java:762)
at oracle.jdbc.driver.OracleStatement.expandSqlEscapes(OracleStatement.java:4790)
at oracle.jdbc.driver.OracleStatement.parseSqlKind(OracleStatement.java:4779)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:209)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:165)
at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:604)
at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:485)
at weblogic.jdbc.common.internal.ConnectionEnv.getStatementHolderForCachedPrepared(ConnectionEnv.java:99)
at weblogic.jdbcbase.jts.Connection.prepareStatement(Connection.java:138)

The Best Answer

Advertisement
Hi. That's clearly an Oracle driver bug. I suggest downloading the latest driver from
Oracle, and making sure it's ahead of all weblogic stuff in the server's weblogic.classpath,
by editing the startWeblogic script.
Joe
Damon Weinstein wrote:
Hello,
I am intermittently getting a nullpointer exception while parsing a
query to make a preparedStatement. I am using WebLogic5.1 sp9.
Oracle 817. Java 1.3.1 The code is very simple (although the
setTypeMap(getTypeMap) stuff is there for ugly historical reasons, it
has been included for completeness). Any insight into this problem
would be greatly appreciated.
My only current theory is that it is related to the nextval being
passed in the string to the prepareStatement.
The exception only happens 1 in 2000 calls. This code usually
succeeds. The code is executing in the context of a stateless session
bean. There may be upto 200 client threads calling this method
concurrently from various systems.
...dAmOn
CODE:
final String lQuery = "insert into SB_MESSAGE (M_MSG_UID,
M_MSG_GUID, M_REQUESTOR_GUID, M_MSG_GROUP, M_MSG_REQ_GUID,
M_DEVICE_UID, M_ACCT_UID, M_TASK_ID, M_COMPLETION_STATUS,
M_LAST_STATE, M_FILTER_NAME, M_FINAL_ATTEMPT, M_START_TIME,
M_COMPLETED_TIME, M_TLM_DT)
values(SEQ_M_MSG_UID.nextval,?,?,?,?,?,?,?,?,?,?,'F',?,?,?) ";
PreparedStatement lPs = null;
Driver driver =
(Driver)Class.forName("weblogic.jdbc20.jts.Driver").newInstance();
Connection connection =
driver.connect("jdbc20:weblogic:jts:myPool", null);
connection.setTypeMap(connection.getTypeMap());
// ** This line leads to the stack trace following the line **
lPs = connection.prepareStatement(lQuery);
Stack Trace:
java.sql.SQLException: java.lang.NullPointerException
at oracle.jdbc.driver.OracleConnection.nativeSQL(OracleConnection.java:762)
at oracle.jdbc.driver.OracleStatement.expandSqlEscapes(OracleStatement.java:4790)
at oracle.jdbc.driver.OracleStatement.parseSqlKind(OracleStatement.java:4779)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:209)
at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:165)
at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:604)
at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:485)
at weblogic.jdbc.common.internal.ConnectionEnv.getStatementHolderForCachedPrepared(ConnectionEnv.java:99)
at weblogic.jdbcbase.jts.Connection.prepareStatement(Connection.java:138)