JDK-6462470 : java.lang.NullPointerException from query object update procedure
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_2.6
  • CPU: x86
  • Submitted: 2006-08-22
  • Updated: 2011-02-16
  • Resolved: 2006-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b98Fixed
The following code (Run with Java DB beta):

import java.sql.*;

public class EODExceptionBug
    interface PersonQ extends BaseQuery {
        @java.sql.Update(sql="create table tab (i integer)")
            int createTable();
    static public void main(String []args) 
        throws Exception
	String driver = "org.apache.derby.jdbc.EmbeddedDriver";
	String url = "jdbc:derby:/tmp/eodbug;create=true";
        Connection conn = DriverManager.getConnection(url);
        PersonQ pq = conn.createQueryObject(PersonQ.class);

        System.out.println("First create");
        System.out.println("Second create");
        try {
        } catch (SQLRuntimeException e) {
            System.out.println("Should end up here, but don't");

Gives the following response:
First create
Second create
java.sql.SQLException: Table/View 'TAB' already exists in Schema 'APP'.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
        at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
        at com.sun.sql.QueryObjectGeneratorImpl.getUpdateImpl(QueryObjectGeneratorImpl.java:543)
        at com.sun.sql.QueryObjectGeneratorImpl.access$200(QueryObjectGeneratorImpl.java:24)
        at com.sun.sql.QueryObjectGeneratorImpl$3.run(QueryObjectGeneratorImpl.java:244)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.sql.QueryObjectGeneratorImpl.invoke(QueryObjectGeneratorImpl.java:239)
        at $Proxy0.createTable(Unknown Source)
        at EODExceptionBug.main(EODExceptionBug.java:24)
Caused by: java.sql.SQLException: Table/View 'TAB' already exists in Schema 'APP'.
        ... 18 more
Exception in thread "main" java.lang.NullPointerException
        at $Proxy0.createTable(Unknown Source)
        at EODExceptionBug.main(EODExceptionBug.java:24)

SUGGESTED FIX The exceptions were caught and there stack trace were being printed instead of throwing those exceptions further. All such cases have been removed. Now all exceptions are thrown. All cases of exception being caught and stack trace being printed are removed. checkin logs Checking in QueryObject.java; /m/jws/jdbc4.0/src/com/sun/sql/QueryObject.java,v <-- QueryObject.java new revision: 1.5; previous revision: 1.4 done

EVALUATION The exceptions were caught and there stack trace were being printed instead of throwing those exceptions further.