Oracle 连续查询通知 ORA-29979

Oracle Continuos query notification ORA-29979

我正在尝试使用 Oracle JDBC 从 Oracle 表 (19c) 注册更改通知。由于查询包含 JOIN 我正在使用 BEST effort 模式。我的用户已被“授予”更改通知权限。

此时我只是想让通知程序接受任何查询。这不是最终版本,但我知道我们需要一个涉及两个表的查询。 将查询更改为更简单的查询,例如 SELECT * from SCDAT.SECURITIES WHERE SCDAT.SECURITIES.INSTYPE = 28 会给出相同的输出。

测试代码

log.info("init changelistener");

    log.info("Get datasource from Spring application context");
    oracleDataSource = context.getBean("dataSource", OracleDataSource.class);

    log.info("Cet Oracle connection from datasource");
    oracle.jdbc.OracleConnection connection = (OracleConnection) oracleDataSource.getConnection();

    Properties properties = new Properties();
    properties.setProperty(OracleConnection.DCN_NOTIFY_ROWIDS, "true");
    properties.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true");
    properties.setProperty(OracleConnection.DCN_BEST_EFFORT, "true");
    log.info("DCN property settings: {}", properties);

    log.info("Register change notification to connection");
    dcr = connection.registerDatabaseChangeNotification(properties);

    //create statement
    Statement stmt = connection.createStatement();

    // associate the statement with the registration:
    ((OracleStatement) stmt).setDatabaseChangeRegistration(dcr);

    log.info("Executing query {}", query);
    ResultSet rs = stmt.executeQuery(query);

    while (rs.next()) {
        // Do Nothing
    }

    log.info("attach listener to the processor");
    dcr.addListener(this);

    String[] tableNames = dcr.getTables();
    for (int i = 0; i < tableNames.length; i++)
        log.info(tableNames[i] + " is part of the registration.");

日志输出

2021-03-30 12:56:15.983  INFO 5180 --- [main] c.c.dbnotifier.OracleChangeListener      : init changelistener
2021-03-30 12:56:15.983  INFO 5180 --- [main] c.c.dbnotifier.OracleChangeListener      : Get datasource from Spring application context
2021-03-30 12:56:15.983  INFO 5180 --- [main] c.c.dbnotifier.OracleChangeListener      : Cet Oracle connection from datasource
2021-03-30 12:56:16.061  INFO 5180 --- [main] c.c.dbnotifier.OracleChangeListener      : DCN property settings: {DCN_QUERY_CHANGE_NOTIFICATION=true, DCN_BEST_EFFORT=true, DCN_NOTIFY_ROWIDS=true}
2021-03-30 12:56:16.061  INFO 5180 --- [main] c.c.dbnotifier.OracleChangeListener      : Register change notification to connection
2021-03-30 12:56:16.077  INFO 5180 --- [main] c.c.dbnotifier.OracleChangeListener      : Executing query SELECT SCDAT.TRANSMAIN.TRANSEX from SCDAT.TRANSMAIN,SCDAT.SECURITIES WHERE SCDAT.TRANSMAIN.SECIK = SCDAT.SECURITIES.SECIK AND SCDAT.SECURITIES.INSTYPE = 28
2021-03-30 12:56:16.295  WARN 5180 --- [main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oracleChangeListener': Invocation of init method failed; nested exception is java.sql.SQLException: ORA-29979: ikke støttet radstørrelse for endringsvarsling for spørringsresultat

这里解释了错误 ORA-29979 https://www.oraexcel.com/database-oracle-11gR2-ORA-29979,但根据 dbadmin,数据库上的兼容设置是 19.0.0。

我应该补充一点,运行 同一用户在 sqldeveloper 中的查询工作正常。

关于如何进行的任何建议或想法?

/卡塔琳娜

您将不得不切换到“table 更改通知”,因为您的table 的列太多而无法支持“查询”更改通知”。 删除此行或将其注释掉:

// properties.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true");