Search in sources :

Example 1 with OracleNotificationListener

use of org.jabref.shared.listener.OracleNotificationListener in project jabref by JabRef.

the class OracleProcessor method startNotificationListener.

@Override
public void startNotificationListener(DBMSSynchronizer dbmsSynchronizer) {
    this.listener = new OracleNotificationListener(dbmsSynchronizer);
    try {
        oracleConnection = (OracleConnection) connection;
        Properties properties = new Properties();
        properties.setProperty(OracleConnection.DCN_NOTIFY_ROWIDS, "true");
        properties.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true");
        databaseChangeRegistration = oracleConnection.registerDatabaseChangeNotification(properties);
        databaseChangeRegistration.addListener(listener);
        try (Statement statement = oracleConnection.createStatement()) {
            ((OracleStatement) statement).setDatabaseChangeRegistration(databaseChangeRegistration);
            StringBuilder selectQuery = new StringBuilder().append("SELECT 1 FROM ").append(escape("ENTRY")).append(", ").append(escape("METADATA"));
            // this execution registers all tables mentioned in selectQuery
            statement.executeQuery(selectQuery.toString());
        }
    } catch (SQLException e) {
        LOGGER.error("SQL Error: ", e);
    }
}
Also used : OracleNotificationListener(org.jabref.shared.listener.OracleNotificationListener) OracleStatement(oracle.jdbc.OracleStatement) SQLException(java.sql.SQLException) Statement(java.sql.Statement) OracleStatement(oracle.jdbc.OracleStatement) Properties(java.util.Properties)

Aggregations

SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 Properties (java.util.Properties)1 OracleStatement (oracle.jdbc.OracleStatement)1 OracleNotificationListener (org.jabref.shared.listener.OracleNotificationListener)1