Class AbstractEmbeddedTrigger

java.lang.Object
org.jumpmind.symmetric.db.AbstractEmbeddedTrigger
Direct Known Subclasses:
H2Trigger, HsqlDbTrigger

public abstract class AbstractEmbeddedTrigger extends Object
An implementation of logic that can be used in Java database triggers to capture data for SymmetricDS.
See Also:
  • Field Details

    • HEX

      protected static final char[] HEX
    • DATE_FORMATTER

      protected static final org.apache.commons.lang3.time.FastDateFormat DATE_FORMATTER
    • KEY_CONDITION_SQL

      protected static final String KEY_CONDITION_SQL
      See Also:
    • KEY_INSERT_DATA_SQL

      protected static final String KEY_INSERT_DATA_SQL
      See Also:
    • TEMPLATE_TABLE_SUFFIX

      protected static final String TEMPLATE_TABLE_SUFFIX
      See Also:
    • triggerName

      protected String triggerName
    • schemaName

      protected String schemaName
    • templates

      protected Map<String,String> 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 database
      triggerName - the name of the trigger used in the CREATE TRIGGER statement
      schemaName - TODO
      tableName - the name of the table
      Throws:
      SQLException
    • fire

      public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException
      This method is called for each triggered action.
      Parameters:
      conn - a connection to the database
      oldRow - 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

      protected Object appendVirtualTableStringValue(Object value, StringBuilder out)
    • readStringAndClose

      protected String readStringAndClose(Reader paramReader, int paramInt) throws IOException
      Throws:
      IOException
    • readBytesAndClose

      public static byte[] readBytesAndClose(InputStream paramInputStream, int paramInt) throws IOException
      Throws:
      IOException
    • convertBytesToString

      public static String convertBytesToString(byte[] paramArrayOfByte)
    • convertBytesToString

      public static String convertBytesToString(byte[] paramArrayOfByte, int paramInt)
    • escapeString

      protected String escapeString(Object val)
    • getTemplates

      protected Map<String,String> getTemplates(Connection conn) throws SQLException
      Throws:
      SQLException