2016-11-01 2 views
0

Oracle 변경 알림을 구현하여 Oracle 데이터베이스를 수신하고 Java 수신기에 대한 변경 사항을 푸시합니다. 이것은 매력처럼 일하고있었습니다. 그러나 어떤 이유로 데이터베이스에서 변경 알림을받지 못합니다. 가능한 결과 일 수 있습니다. 필자는 Oracle 문서에서 이에 대한 충분한 정보를 보지 못했습니다.Oracle 알림 알림 수신자가 없음

USER_CHANGE_NOTIFICATION_REGS 테이블에 등록 된 연결이 표시됩니다. 그러나 나는 어떤 기대도하지 않습니다.

void run() throws SQLException { 
    OracleConnection conn = connect(); 

    Properties prop = new Properties(); 
    prop.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true"); 
    DatabaseChangeRegistration dcr = conn.registerDatabaseChangeNotification(prop); 
    // add the listenerr: 
    dcr.addListener(new MyListener()); 

    // second step: add objects in the registration: 
    Statement stmt = conn.createStatement(); 
    // associate the statement with the registration: 
    ((OracleStatement) stmt).setDatabaseChangeRegistration(dcr); 
    ResultSet rs = stmt.executeQuery("SELECT * FROM MY_TABLE where MY_FLAG = '3'"); 
    while (rs.next()) { 
    } 
    String[] tableNames = dcr.getTables(); 
    for (int i = 0; i < tableNames.length; i++) { 
     System.out.println(tableNames[i] + " is part of the registration."); 
    } 
    rs.close(); 
    stmt.close(); 

} 


public class MyListener implements DatabaseChangeListener { 

    public void onDatabaseChangeNotification(DatabaseChangeEvent dce) { 
     System.out.println("Change is found"); 

    } 
} 

답변

0

확인 문제가 발견되었습니다. 오라클 버전은 10g입니다. 오라클에 따르면이는 11g 이전 버전에서는 지원되지 않습니다

11g 릴리스 1 (11.1), 오라클 JDBC 드라이버는 오라클 데이터베이스의 데이터베이스 변경 알림 기능에 대한 지원을 제공에서 시작