Oracle CDC LogMiner Adapter Sample

This sample demonstrates the use of the Oracle CDC LogMiner Connection and Parser adapters.

Note

Oracle Corporation does not include its LogMiner feature on Oracle 19c, which means this adapter cannot work with that Oracle release.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top menu, click File>Import Samples and Community Content.

  • Enter logminer to narrow the list of options.

  • Select Oracle LogMiner Change Data Capture input adapter from the Native Database Connectivity Adapters list.

  • Click Import Now.

StreamBase Studio creates a project for this sample.

Setting up Oracle LogMiner

  1. Make sure your database is set up correctly and has supplemental logging enabled.

    1. Enable LogMiner:

      1. Log onto your database using a user with DBA privileges.

      2. Check the current log level by running select log_mode from v$database; If the command returns LOG_MODE of ARCHIVELOG then logging is already enabled and you can skip the following steps. If the command returns NOARCHIVELOG then you must enable logging.

      3. To enable logging, first shut down the database using shutdown immediate;.

      4. Then start up and mount the database using startup mount;.

      5. Now configure the database to enable archive log using alter database archivelog; and alter database open;.

    2. Enabled Supplemental Logging using ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

    3. If you require primary key information, you can enable logging for each table with ALTER TABLE 'schema'.'table name' ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS; or for the entire database ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;

    4. You can also enable full logging for each table with ALTER TABLE 'schema'.'table name' ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS; or for the entire database ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

    5. Submit the changes using ALTER SYSTEM SWITCH LOGFILE;

  2. This sample provides scripts to create a SAMPLE table and perform insert/update/delete tasks on the table. The adapters in the sample are set up for the SAMPLE table. The Oracle CDC LogMiner Connection adapter properties do need to be updated with the correct database information in order to connect.

    The following scripts are provided:

    • CreateSampleTable.sql — This SQL script creates the SAMPLE table which the adapters are set up to capture CDC information.

    • InsertSampleData.sql — This SQL script inserts 10 demo records into the SAMPLE table.

    • UpdateSampleData.sql — This SQL script updates the 10 demo records in the SAMPLE table with new values.

    • DeleteSampleData.sql — This SQL script deletes the 10 demo records from the SAMPLE table.

  3. Load the JAR file containing the JDBC driver for your database into the Maven dependency system as described in Using External JAR Files.

Running This Sample in StreamBase Studio

  1. In the Project Explorer, double-click Sample.sbapp to open the sample application.

  2. Select the Connection adapter and open its Properties view.

  3. Open the Connection tab and configure the connection for your database.

  4. Click the Run button. This opens the SB Test/Debug perspective and starts the application.

  5. In the Studio's Output Streams view, observe tuples emitted on the adapter's Status output ports, indicating a connection was made to the database and tables are being monitored.

  6. Using a tool such as Oracle SQL Developer, use the supplied script files to create the SAMPLE table and perform CRUD operations.

  7. In Studio's Output Streams view, observe tuples emitted on the TestTableData and AllGenericData output ports indicating changes were made to the SAMPLE table.

  8. When done, press F9 or click the Stop Running Application button.

Sample Location

When you load the sample into StreamBase® Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase® Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:

studio-workspace/adapter/embedded/oracle-cdc-logminer

See Default Installation Directories for the default location of studio-workspace on your system.