简体   繁体   English

没有来自Oracle Change Notification Listener的通知

[英]No Notification from Oracle Change Notification Listener

I have implemented Oracle Change Notification to listen to an oracle database and push changes to a Java listener. 我已经实现了Oracle Change Notification,以侦听oracle数据库并将更改推送到Java侦听器。 This was working like charm. 这就像魅力。 However, for some reason I'm not receiving any change notification from the database anymore. 但是,由于某种原因,我不再从数据库收到任何更改通知。 What could be the possible results. 可能是什么结果。 I don't see enough information about it in Oracle documents. 我在Oracle文档中看不到足够的信息。

I do see the connection registered in the USER_CHANGE_NOTIFICATION_REGS table. 我的确在USER_CHANGE_NOTIFICATION_REGS表中注册了该连接。 But I'm not receiving any pushes. 但是我没有收到任何推动。

void run() throws SQLException {
    OracleConnection conn = connect();

    Properties prop = new Properties();
    prop.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true");
    DatabaseChangeRegistration dcr = conn.registerDatabaseChangeNotification(prop);
    // add the listenerr:
    dcr.addListener(new MyListener());

    // second step: add objects in the registration:
    Statement stmt = conn.createStatement();
    // associate the statement with the registration:
    ((OracleStatement) stmt).setDatabaseChangeRegistration(dcr);
    ResultSet rs = stmt.executeQuery("SELECT * FROM MY_TABLE where MY_FLAG = '3'");
    while (rs.next()) {
    }
    String[] tableNames = dcr.getTables();
    for (int i = 0; i < tableNames.length; i++) {
        System.out.println(tableNames[i] + " is part of the registration.");
    }
    rs.close();
    stmt.close();

}


public class MyListener implements DatabaseChangeListener {

    public void onDatabaseChangeNotification(DatabaseChangeEvent dce) {
        System.out.println("Change is found");

    }
}

Ok I found the problem. 好的,我发现了问题。 Oracle version is 10g. Oracle版本是10g。 and according to oracle this is not supported in versions prior to 11g: 并且根据oracle,在11g之前的版本中不支持此功能:

Starting from 11g Release 1 (11.1), Oracle JDBC drivers provide support for the Database Change Notification feature of Oracle Database 从11g第1版(11.1)开始,Oracle JDBC驱动程序提供对Oracle数据库的数据库更改通知功能的支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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