简体   繁体   English

Oracle Continuos 查询通知 ORA-29979

[英]Oracle Continuos query notification ORA-29979

I'm attempting to register change notifications from Oracle tables (19c) using Oracle JDBC.我正在尝试使用 Oracle JDBC 从 Oracle 表 (19c) 注册更改通知。 Since the query contains a JOIN I'm using BEST effort mode.由于查询包含一个 JOIN 我正在使用 BEST 努力模式。 My user has been "granted" CHANGE NOTIFICATION rights.我的用户已被“授予”更改通知权限。

At this point I'm just trying to get the notifier accept any query.在这一点上,我只是想让通知者接受任何查询。 This is not the final version but I do know that we'll need a query that involves two tables with a join.这不是最终版本,但我知道我们需要一个涉及两个表的查询。 Changing the query to something simpler like SELECT * from SCDAT.SECURITIES WHERE SCDAT.SECURITIES.INSTYPE = 28 gives the same output.将查询更改为更简单的查询,如SELECT * from SCDAT.SECURITIES WHERE SCDAT.SECURITIES.INSTYPE = 28给出相同的 output。

Test code测试代码

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.");

Log output日志 output

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

The error ORA-29979 is explained here https://www.oraexcel.com/database-oracle-11gR2-ORA-29979 but the COMPATIBLE setting is 19.0.0 on the database according to dbadmin.这里解释了错误 ORA-29979 https://www.oraexcel.com/database-oracle-11gR2-ORA-29979但根据 dbadmin,数据库上的 COMPATIBLE 设置为 19.0.0。

I should add that running the queries in sqldeveloper with same user works fine.我应该补充一点,使用同一用户在 sqldeveloper 中运行查询可以正常工作。

Any suggestions or ideas on how to proceed?关于如何进行的任何建议或想法?

/Katarina /卡特琳娜

You will have to switch to " table change notification " because your table has too many columns to support " query change notification ".您将不得不切换到“表更改通知”,因为您的表有太多列以支持“查询更改通知”。 Remove this line or comment it out:删除此行或将其注释掉:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM