简体   繁体   中英

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. 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.

I do see the connection registered in the USER_CHANGE_NOTIFICATION_REGS table. 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. and according to oracle this is not supported in versions prior to 11g:

Starting from 11g Release 1 (11.1), Oracle JDBC drivers provide support for the Database Change Notification feature of Oracle Database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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