【问题标题】:Null pointer exception in oracle-jdbc database change notificationoracle-jdbc 数据库更改通知中的空指针异常
【发布时间】:2015-01-04 06:56:21
【问题描述】:
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();}
      }

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

【问题讨论】:

  • 这样的行是调试的噩梦。将其分解为多行,然后您将有机会弄清楚:e.getTableChangeDescription()[0].getRowChangeDescription()[0].getRowid().stringValue()
  • 错误在第 142 行,即 'System.out.println(e.getTableChangeDescription()[0].getRowChangeDescription()[0].getRowid().stringValue());' // 第 142 行
  • 我该如何分解?
  • 将每个部分分配给自己的变量并检查它

标签: java multithreading jdbc


【解决方案1】:

修复它。我实际上是想弄清楚我编写的代码,在这样做的同时,我从一个网站上复制了一些代码,该网站正在提取一条在 DB 中为空的记录,因此出现了错误。删除第 142 行的代码修复了问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多