【发布时间】: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