title: Oracle Change Notification not firing when table changes
body: <p>First time trying to do something like this and I'm not sure what I am missing?</p>
  
  <p>My code:</p>
  
  <pre><code>package SQLOCpackage;
  import java.awt.BorderLayout;
  import java.awt.EventQueue;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.Properties;    
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.border.EmptyBorder;    
  import oracle.jdbc.OracleConnection;
  import oracle.jdbc.OracleStatement;
  import oracle.jdbc.dcn.DatabaseChangeEvent;
  import oracle.jdbc.dcn.DatabaseChangeListener;
  import oracle.jdbc.dcn.DatabaseChangeRegistration;
  import oracle.jdbc.dcn.RowChangeDescription;
  import oracle.jdbc.dcn.TableChangeDescription;
  
  @SuppressWarnings("serial")
  public class SQLONframe extends JFrame {
  String URL = "jdbc:oracle:thin:@xxxxx.xxxxx.xx.xxxx:1521:xxxxx";
  Properties prop;
  private JPanel contentPane;
  static String PW                    = "xxxxxxxx";
  static String UN                    = "xxxxxxxx";
  
  public static void main(String[] args) {
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  SQLONframe frame = new SQLONframe();
                  frame.setVisible(true);
  
                  SQLONframe dcn = new SQLONframe();
                  try {
                    dcn.prop = new Properties();
                    dcn.prop.setProperty("user", UN);
                    dcn.prop.setProperty("password", PW);
                    dcn.run();
                  }
                  catch(Exception e) {
                    e.printStackTrace();
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      });
  }
  
  public SQLONframe() {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setBounds(100, 100, 450, 300);
      contentPane = new JPanel();
      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      contentPane.setLayout(new BorderLayout(0, 0));
      setContentPane(contentPane);
  }
  
  void run() throws SQLException {
      OracleConnection conn = (OracleConnection)DriverManager.getConnection(URL,prop);
      DatabaseChangeRegistration dcr = null;
      Properties prop = new Properties();
      prop.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION,"true");
  
      try {
        dcr = conn.registerDatabaseChangeNotification(prop);
        dcnListener list = new dcnListener(this);
        dcr.addListener(list);
  
        Statement stmt = conn.createStatement();
        ((OracleStatement)stmt).setDatabaseChangeRegistration(dcr);
        ResultSet rs = stmt.executeQuery("select script_name, current_status, Issues_found_during_run, Testers, tools from ALLDATA WHERE ID = 1");
        while (rs.next())
        {
  
            }
  
        String[] tableNames = dcr.getTables();
        for(int i=0;i&lt;tableNames.length;i++)
          System.out.println(tableNames[i]+" is part of the registration.");
  
        rs.close();
        stmt.close();
      }
      catch(Exception e) {
        //clean up our registration
        if(conn != null)
          conn.unregisterDatabaseChangeNotification(dcr);
        e.printStackTrace();
      }
      finally {
        try {
          conn.close();
        }
        catch(Exception e){
          e.printStackTrace();
        }
      }
  
      try {
        Thread.currentThread().join();
      }
      catch (Exception e) {
        e.printStackTrace();
      }
  
      finally {
        OracleConnection conn3 = (OracleConnection)DriverManager.getConnection(URL,prop);
        conn3.unregisterDatabaseChangeNotification(dcr);
        conn3.close();
      }
    }
  
  
  class dcnListener implements DatabaseChangeListener {
      SQLONframe dcn;
    dcnListener(SQLONframe dem) {
      dcn = dem;
    }
  
    public void onDatabaseChangeNotification(DatabaseChangeEvent e) {
      TableChangeDescription[] tc = e.getTableChangeDescription();
  
      for (int i = 0; i &lt; tc.length; i++) {
        RowChangeDescription[] rcds = tc[i].getRowChangeDescription();
        for (int j = 0; j &lt; rcds.length; j++) {
          System.out.println(rcds[j].getRowOperation() + " " + rcds[j].getRowid().stringValue());
        }
      }
      synchronized( dcn ){
        dcn.notify();
      }
    }
  
  }
   }
  </code></pre>
  
  <p>I can see that it does register the Change Notification but when I go and change something in that table and commit it I never get anything on the code side saying something has changed?</p>
  
  <p>Any help would be great!</p>
  
  <p><strong>update</strong></p>
  
  <p>Using </p>
  
  <pre><code>SELECT * from USER_CHANGE_NOTIFICATION_REGS 
  </code></pre>
  
  <p>I do get a reg back when doing that query in SQL Developer:</p>
  
  <p><a href="https://i.stack.imgur.com/NRNvd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NRNvd.png" alt="enter image description here"></a></p>
  
  <p>And the ojdbc8.jar version info is:</p>
  
  <blockquote>
    <p>Oracle 18.3.0.0.0 JDBC 4.2 compiled with javac 1.8.0_171 on </p>
    
    <p>Tue_Jun_26_11:06:40_PDT_2018</p>
    
    <p>Default Connection Properties Resource</p>
    
    <p>Tue Mar 12 10:06:48 EDT 2019</p>
  </blockquote>
  
  <p>and this is the Oracle SQL Developer status:</p>
  
  <blockquote>
    <p>Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production</p>
    
    <p>PL/SQL Release 12.2.0.1.0 - Production</p>
    
    <p>"CORE  12.2.0.1.0  Production"</p>
    
    <p>TNS for Linux: Version 12.2.0.1.0 - Production</p>
    
    <p>NLSRTL Version 12.2.0.1.0 - Production</p>
  </blockquote>
  
  <p>and with my program running and the query registered this is what I see for ports:</p>
  
  <p><a href="https://i.stack.imgur.com/6D5Wd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6D5Wd.jpg" alt="enter image description here"></a></p>