Reputation: 95
Tried out this code for Informix Change Streams API for Java . from https://informix.hcldoc.com/14.10/help/index.jsp?topic=%2Fcom.ibm.cdc.doc%2Fids_cdc_streamapi.htm
I Keep on getting this error .Is there any fix for this or solution??
16:03:57.054 [main] DEBUG com.informix.stream.cdc.IfxCDCEngine - Closing down CDC engine
Exception in thread "main" java.sql.SQLException: Routine (cdc_opensess) can not be resolved.
at com.informix.util.IfxErrMsg.buildExceptionWithMessage(IfxErrMsg.java:422)
at com.informix.util.IfxErrMsg.buildIsamException(IfxErrMsg.java:401)
at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3022)
at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3273)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2194)
at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java:1194)
at com.informix.jdbc.IfxPreparedStatement.setupExecutePrepare(IfxPreparedStatement.java:245)
at com.informix.jdbc.IfxCallableStatement.<init>(IfxCallableStatement.java:143)
at com.informix.jdbc.IfxSqliConnect.prepareCall(IfxSqliConnect.java:5924)
at com.informix.jdbc.IfxSqliConnect.prepareCall(IfxSqliConnect.java:2499)
at com.informix.stream.cdc.IfxCDCEngine.init(IfxCDCEngine.java:177)
at com.example.informixchangestream.demo.CDCExDemoApplicationample.main(CDCExDemoApplicationample.java:33)
Suppressed: com.informix.stream.impl.IfxStreamException: Unable to end cdc capture
at com.informix.stream.cdc.IfxCDCEngine.endCapture(IfxCDCEngine.java:295)
at com.informix.stream.cdc.IfxCDCEngine.unwatchTable(IfxCDCEngine.java:275)
at com.informix.stream.cdc.IfxCDCEngine.close(IfxCDCEngine.java:343)
at com.example.informixchangestream.demo.CDCExDemoApplicationample.main(CDCExDemoApplicationample.java:52)
Caused by: java.sql.SQLException: Routine (cdc_endcapture) can not be resolved.
at com.informix.util.IfxErrMsg.buildExceptionWithMessage(IfxErrMsg.java:422)
at com.informix.util.IfxErrMsg.buildIsamException(IfxErrMsg.java:401)
at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3022)
at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3273)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2194)
at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java:1194)
at com.informix.jdbc.IfxPreparedStatement.setupExecutePrepare(IfxPreparedStatement.java:245)
at com.informix.jdbc.IfxCallableStatement.<init>(IfxCallableStatement.java:143)
at com.informix.jdbc.IfxSqliConnect.prepareCall(IfxSqliConnect.java:5924)
at com.informix.jdbc.IfxSqliConnect.prepareCall(IfxSqliConnect.java:2499)
at com.informix.stream.cdc.IfxCDCEngine.endCapture(IfxCDCEngine.java:282)
... 3 more
My code looks like this :
try (IfxCDCEngine engine = builder.build()) {
// initialize the engine (creates the connections and begins listening for
// changes)
engine.init();
IfmxStreamRecord record = null;
// This loop is where you can inject logic that compiles
// transactions, look for commits, throw away rollbacks
// The data here is all Java typed, so it can be easily then
// sent to MQTT, other JDBC drivers, streaming engines, or anything
// else you can think of.
while ((record = engine.getRecord()) != null) {
// Print out the basic record information
System.out.println("record changed");
System.out.println(record);
// If it is an insert/update/delete, print the column data
if (record.hasOperationData()) {
System.out.println("operation data");
System.out.println(((IfxCDCOperationRecord) record).getData());
}
}
}
Upvotes: 1
Views: 596
Reputation: 683
This error is happens when the CDC routines are not found. Make sure that you first run the CDC setup script with the server to create the syscdcv1
database.
Then make sure your DataSource connects to the syscdcv1
database when you try CDC operations. It's not intuitive, but you 'connect' to the syscdcv1
database, then add watchers
on databases and tables you are interested in getting the changes for.
Documentation on the CDC setup on the server is here, you need step #2 at least. https://informix.hcldoc.com/14.10/help/index.jsp?topic=%2Fcom.ibm.cdc.doc%2Fids_cdc_streamapi.htm
A working example can be found here with a README and java code that you can use that might be easier to follow than the pages of the official docs https://github.com/informix/informix-db-examples/tree/master/streaming/cdc
Upvotes: 1