简体   繁体   中英

Null pointer exception in oracle-jdbc database change notification

DCNDemoListener: got an event (com.datasync.DCNDemoListener@587bf0 running on thread Thread[Thread-2,5,main])
Exception in thread "Thread-2" java.lang.NullPointerException
    at com.datasync.DCNDemoListener.onDatabaseChangeNotification(DBChangeNotification.java:142)
    at oracle.jdbc.driver.NTFRegistration.notify(NTFRegistration.java:191)
    at oracle.jdbc.driver.NTFConnection.unmarshalNSDataPacket(NTFConnection.java:578)
    at oracle.jdbc.driver.NTFConnection.unmarshalOneNSPacket(NTFConnection.java:404)
    at oracle.jdbc.driver.NTFConnection.run(NTFConnection.java:181)

Here is my code:

public void onDatabaseChangeNotification(DatabaseChangeEvent e)
      {
        Thread t = Thread.currentThread();
        System.out.println("DCNDemoListener: got an event ("+this+" running on thread "+t+")");
        System.out.println(e.getTableChangeDescription()[0].getRowChangeDescription()[0].getRowid().stringValue()); // line142
        System.out.println(e.toString());
        synchronized( demo )
        { demo.notify();}
      }

Tring to figure out but I have no clue what went wrong :(

Fixed it. I was actually trying to figure out the code I have written and while doing so I have copied a bit of code from a website which was pulling a record which is null in DB hence the error. Removing the code at line 142 fixed the isse

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM