Уведомление об изменении базы данных Oracle в Quarkus 3.0.3.Final

Я новичок в уведомлении об изменении базы данных Oracle. используя этот код, я получаю исключение, когда выполнение включеноstmt.execute("SELECT e.EMPLOYEE_ID, e.FIRST_NAME, e.LAST_NAME FROM EMPLOYEES e WHERE e.EMPLOYEE_ID > 1");нужна помощь в этом, как это исправить.

      @ApplicationScoped
public class ChangeRegistrar {

    @Inject
    Logger log;

    @Inject
    DatabaseChangeNotificationListener listener;

    @Inject
    DataSource dataSource;

    private DatabaseChangeRegistration dcr;
    private OracleConnection conn;

    public synchronized void register() throws SQLException {

        try {
            this.conn = this.dataSource.getConnection().unwrap(OracleConnection.class);

            Properties prop = new Properties();
            prop.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true");
            prop.setProperty(OracleConnection.DCN_BEST_EFFORT, "true");
            prop.setProperty(OracleConnection.DCN_CLIENT_INIT_CONNECTION, "true");
            this.dcr = this.conn.registerDatabaseChangeNotification(prop);

            this.dcr.addListener(listener);
            OracleStatement stmt = this.conn.createStatement().unwrap(OracleStatement.class);
            stmt.setDatabaseChangeRegistration(this.dcr);
            // ResultSet rs = stmt.executeQuery("select * from employees");
            if (dcr != null && dcr.getState().equals(NotificationRegistration.RegistrationState.ACTIVE)) {
                stmt.execute("SELECT e.EMPLOYEE_ID, e.FIRST_NAME, e.LAST_NAME FROM EMPLOYEES e WHERE e.EMPLOYEE_ID > 1");
                ResultSet rs = stmt.getResultSet();
                while (rs.next()) {
                }
                String[] tableNames = this.dcr.getTables();
                for (int i = 0; i < tableNames.length; i++) {
                    System.out.println(tableNames[i] + " is part of the registration.");
                }
                rs.close();
            } else {
                log.fatal("Houston we got a problem here");
            }

            stmt.close();
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
            unregister();
            throw ex;
        }
    }

// rest of the code here
}

Я нашел этот код и заставил его работать, но когда я пытаюсь использовать Quarkus и AgroalDatasource, я получил ту же ошибку, что и с моим кодом.

тоже пробовал это решение , но в моем случае оно не работает

0 ответов

Другие вопросы по тегам