|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.connector.Connector
com.ibm.di.connector.JDBCConnector
com.ibm.di.connector.DBChangelogConnector
public class DBChangelogConnector
The DBChangelogConnector provides a way to to detect changes in specific RDBMS tables. The Connector connects to the underline database through JDBC driver and creates Entries from specific 'change table' containing one record per modified record in the target table.
The Connector regularly saves current state into the System Store to avoid duplications when retrieving Entries. Records can also be deleted after the retrieving.
Field Summary |
---|
Fields inherited from class com.ibm.di.connector.Connector |
---|
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER |
Fields inherited from interface com.ibm.di.connector.ChangelogInterface |
---|
CONN_PARAM_STATE_KEY_PERSISTENCE, PARAM_MERGE_BOTH_NOT_MERGED, PARAM_MERGE_CHANGELOG_AND_DATA, PARAM_MERGE_ONLY_CHANGED_DATA, PARAM_VAL_AFTER_READ, PARAM_VAL_END_OF_CYCLE, PARAM_VAL_MANUAL, SAVE_STATE_AFTER_READ, SAVE_STATE_END_OF_CYCLE, SAVE_STATE_MANUAL |
Constructor Summary | |
---|---|
DBChangelogConnector()
Constructor for the DBChangelogConnector object. |
Method Summary | |
---|---|
java.lang.String |
ctString(java.lang.Object ct)
Converts the Object to String. |
boolean |
doWait()
This method sleeps for a number of seconds specified by the 'Sleep Interval' parameter. |
Entry |
getNextEntry()
Gets the next Entry object from the 'change table'. |
static int |
getNumberOfRecords(java.lang.String tableName,
java.sql.Connection con)
This method extracts the number of records in the changelog table. |
java.lang.Object |
getStateKeyObject()
This method returns the StateKey used as our Change Detection number. |
int |
getStateKeySaveMethod()
Retrieves the method for storing StateKey. |
java.lang.String |
getVersion()
Version information. |
void |
initialize(java.lang.Object o)
Reads Connector parameter's values and initialize the Connector. |
void |
removeProcessedRows()
Removes processed rows from the 'change table'. |
void |
reselect()
Retrieves records from the 'change table' using the current value of the StateKey. |
void |
saveStateKey()
Stores the USN values for the next synchronization. |
void |
selectEntries()
This method prepares the Connector for a sequential read. |
java.lang.String |
toHex(int n)
Converts integer to Hex String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.ibm.di.connector.ConnectorInterface |
---|
deleteEntry, findEntry, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, modEntry, modEntry, pushback, putEntry, queryOperations, queryReply, querySchema, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminate, terminateServer |
Constructor Detail |
---|
public DBChangelogConnector()
Method Detail |
---|
public void initialize(java.lang.Object o) throws java.lang.Exception
initialize
in interface ConnectorInterface
initialize
in class JDBCConnector
o
- Socket object, ConnectorMode object or null
java.lang.Exception
- If invalid Connector parameter values are supplied.public void selectEntries() throws java.lang.Exception
selectEntries
in interface ConnectorInterface
selectEntries
in class JDBCConnector
java.lang.Exception
- If an error occurs while selecting EntriesJDBCConnector.getNextEntry()
public void reselect() throws java.lang.Exception
null
and 'Remove Processed Row' parameter is
true
- the processed rows are deleted from the 'change
table'null
and 'Remove Processed Row' parameter is
false
- all entries are retrievednull
- only entries with ibmsnap_commitseq >
StateKey are retrieved
java.lang.Exception
- If an error occurs while retrieving records from the databasepublic void removeProcessedRows() throws java.lang.Exception
ibmsnap_commitseq <= StateKey
. These rows
are actually already returned as entries by the
getNextEntry()
function.
This method is called from the reselect() method only if the parameter
'Removed Processed Rows' is set to true
.
java.lang.Exception
- If the Connector can not delete processed rows in the
databasepublic java.lang.String ctString(java.lang.Object ct)
Example:
By using this method you can print the values of the IBMSNAP_COMMITSEQ
and IBMSNAP_INTENTSEQ properties of the read entry.
var csn = conn.getProperty("IBMSNAP_COMMITSEQ"); task.logmsg("IBMSNAP_COMMITSEQ: "+RDBMS.connector.ctString(csn); var isn = conn.getProperty("IBMSNAP_INTENTSEQ"); task.logmsg("IBMSNAP_INTENTSEQ: "+RDBMS.connector.ctString(isn);
ct
- the Object that need to be converted
public java.lang.String toHex(int n)
n
- the integer that need to be converted to Hex String
public Entry getNextEntry() throws java.lang.Exception
getNextEntry
in interface ConnectorInterface
getNextEntry
in class JDBCConnector
java.lang.Exception
- If retrieving the next Entry fails.ConnectorInterface.selectEntries()
public boolean doWait() throws java.lang.Exception
It is called by the getNextEntry()
method after an entry
is retrieved from the 'change table' to make the connector
sleep for a specified interval of time before polling for next entry.
If no new entries are added to the 'change table' for a timeout value
the getNextEntry() method will return null
.
java.lang.Exception
- if an error occurs during sleeping.public int getStateKeySaveMethod() throws java.lang.Exception
getStateKeySaveMethod
in interface ChangelogInterface
java.lang.Exception
- -
neverChangelogInterface.SAVE_STATE_AFTER_READ
,
ChangelogInterface.SAVE_STATE_END_OF_CYCLE
,
ChangelogInterface.SAVE_STATE_MANUAL
public void saveStateKey() throws java.lang.Exception
ChangelogInterface.SAVE_STATE_AFTER_READ
saveStateKey
in interface ChangelogInterface
java.lang.Exception
- -
neverpublic java.lang.Object getStateKeyObject() throws java.lang.Exception
Example:
Here is an example how to print the StateKey using this method.
key statekey = conn.getStateKeyObject(); task.logmsg("Iterator State Key: " + thisConnector.connector.ctString(statekey));return an Object representing the commit sequence number of the last processed record throws Exception if an error occurs.
getStateKeyObject
in interface ChangelogInterface
java.lang.Exception
- if an error occurs.ChangelogInterface
public java.lang.String getVersion()
getVersion
in interface VersionInfoInterface
getVersion
in class JDBCConnector
public static int getNumberOfRecords(java.lang.String tableName, java.sql.Connection con) throws java.lang.Exception
tableName
- name of the changelog tablecon
- Connection handle for the currently opened session to the
database
java.lang.Exception
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |