0

am currently trying to trigger an event in my spring application after detecting that a line has been inserted in a Oracle database table.Having limited knowledge on databases and PL/SQL ,am struggling to find the best approche. Note : the insertion in that table happens inside another software which means i can't manage it inside the application that am working on.

rbm
  • 57
  • 9

1 Answers1

0

If you are using Oracle you can make use of DatabaseChangeListener

Something like this

public class DBListener implements DatabaseChangeListener {
    private DbChangeNotification toNotify;

    public BNSDBListener(DbChangeNotification toNotify) {
        this.toNotify = toNotify;
    }

    @Override
    public void onDatabaseChangeNotification(oracle.jdbc.dcn.DatabaseChangeEvent e) {
        synchronized( toNotify ) {
            try {
                toNotify.notifyDBChangeEvent(e); 
            } catch (Exception ex) {
                Util.logMessage(CLASSNAME, "onDatabaseChangeNotification", 
                    "Errors on the notifying object.", true);
                Util.printStackTrace(ex);
                Util.systemExit();                                       
            }
        }       
    }
}

More info here

MyTwoCents
  • 7,284
  • 3
  • 24
  • 52