oracle-jdbc数据库更改通知中的空指针异常

时间:2015-01-04 06:56:21

标签: java multithreading jdbc

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)

这是我的代码:

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();}
      }

试图弄清楚,但我不知道出了什么问题:(

1 个答案:

答案 0 :(得分:1)

修正了它。我实际上是想弄清楚我写的代码,并且在这样做的时候,我从一个网站上复制了一些代码,这个代码正在拉取一条在DB中为空的记录,因此错误。删除第142行的代码修复了isse