Package org.jumpmind.symmetric.db
Class AbstractEmbeddedTrigger
java.lang.Object
org.jumpmind.symmetric.db.AbstractEmbeddedTrigger
- Direct Known Subclasses:
H2Trigger,HsqlDbTrigger
An implementation of logic that can be used in Java database triggers to capture data for SymmetricDS.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectappendVirtualTableStringValue(Object value, StringBuilder out) static StringconvertBytesToString(byte[] paramArrayOfByte) static StringconvertBytesToString(byte[] paramArrayOfByte, int paramInt) protected StringescapeString(Object val) protected StringfillVirtualTableSql(String sql, Object[] oldRow, Object[] newRow) voidfire(Connection conn, Object[] oldRow, Object[] newRow) This method is called for each triggered action.getTemplates(Connection conn) protected voidinit(Connection conn, String triggerName, String schemaName, String tableName) This method should be called by the database engine once when initializing the trigger.static byte[]readBytesAndClose(InputStream paramInputStream, int paramInt) protected StringreadStringAndClose(Reader paramReader, int paramInt)
-
Field Details
-
HEX
protected static final char[] HEX -
DATE_FORMATTER
protected static final org.apache.commons.lang3.time.FastDateFormat DATE_FORMATTER -
KEY_CONDITION_SQL
- See Also:
-
KEY_INSERT_DATA_SQL
- See Also:
-
TEMPLATE_TABLE_SUFFIX
- See Also:
-
triggerName
-
schemaName
-
templates
-
-
Constructor Details
-
AbstractEmbeddedTrigger
public AbstractEmbeddedTrigger()
-
-
Method Details
-
init
protected void init(Connection conn, String triggerName, String schemaName, String tableName) throws SQLException This method should be called by the database engine once when initializing the trigger.- Parameters:
conn- a connection to the databasetriggerName- the name of the trigger used in the CREATE TRIGGER statementschemaName- TODOtableName- the name of the table- Throws:
SQLException
-
fire
This method is called for each triggered action.- Parameters:
conn- a connection to the databaseoldRow- the old row, or null if no old row is available (for INSERT)newRow- the new row, or null if no new row is available (for DELETE)- Throws:
SQLException- if the operation must be undone
-
fillVirtualTableSql
protected String fillVirtualTableSql(String sql, Object[] oldRow, Object[] newRow) throws SQLException - Throws:
SQLException
-
appendVirtualTableStringValue
-
readStringAndClose
- Throws:
IOException
-
readBytesAndClose
public static byte[] readBytesAndClose(InputStream paramInputStream, int paramInt) throws IOException - Throws:
IOException
-
convertBytesToString
-
convertBytesToString
-
escapeString
-
getTemplates
- Throws:
SQLException
-