繁体   English   中英

没有来自Oracle Change Notification Listener的通知

[英]No Notification from Oracle Change Notification Listener

我已经实现了Oracle Change Notification,以侦听oracle数据库并将更改推送到Java侦听器。 这就像魅力。 但是,由于某种原因,我不再从数据库收到任何更改通知。 可能是什么结果。 我在Oracle文档中看不到足够的信息。

我的确在USER_CHANGE_NOTIFICATION_REGS表中注册了该连接。 但是我没有收到任何推动。

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");

    }
}

好的,我发现了问题。 Oracle版本是10g。 并且根据oracle,在11g之前的版本中不支持此功能:

从11g第1版(11.1)开始,Oracle JDBC驱动程序提供对Oracle数据库的数据库更改通知功能的支持

暂无
暂无

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

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