Class JdbcMapInsert

All Implemented Interfaces:
AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, ConfigComment, ConnectedService, MessageEventGenerator, Service, StateManagedComponent
Direct Known Subclasses:
JdbcMapUpsert

public abstract class JdbcMapInsert extends JdbcService
Base behaviour of inserting Objects directly into a db.
  • Constructor Details

    • JdbcMapInsert

      public JdbcMapInsert()
  • Method Details

    • getTable

      public String getTable()
      Returns:
      the table
    • setTable

      public void setTable(String s)
      Parameters:
      s - the table to insert on.
    • table

      protected String table(AdaptrisMessage msg)
    • withTable

      public <T extends JdbcMapInsert> T withTable(String s)
    • getFieldMappings

      public KeyValuePairSet getFieldMappings()
    • setFieldMappings

      public void setFieldMappings(KeyValuePairSet mappings)
      Set the converters for various fields in the map.

      In the event that the database doesn't auto-convert types (e.g. MySQL will convert 2017-01-01 into a DATE if that is the column type); you can specify the java type that the string should be converted to; if the type cannot be handled automagically then it is assumed to be a fully qualified classname with a String constructor.

      Parameters:
      mappings - the key is the key in the map (e.g. the JSON fieldname), the value is the JdbcMapInsert.BasicType that we should attempt to convert to
      See Also:
    • withMappings

      public <T extends JdbcMapInsert> T withMappings(KeyValuePairSet s)
    • buildStatementParam

      protected JdbcMapInsert.StatementParam buildStatementParam(String key, String value)
    • closeJdbcService

      protected void closeJdbcService()
      Description copied from class: JdbcService
      Close the service.

      This is called before the connection is closed

      Specified by:
      closeJdbcService in class JdbcService
    • initJdbcService

      protected void initJdbcService() throws CoreException
      Specified by:
      initJdbcService in class JdbcService
      Throws:
      CoreException
    • prepareService

      protected void prepareService() throws CoreException
      Specified by:
      prepareService in class JdbcService
      Throws:
      CoreException
    • startService

      protected void startService() throws CoreException
      Description copied from class: JdbcService
      Start the service.

      This is called after the connection is started

      Specified by:
      startService in class JdbcService
      Throws:
      CoreException
    • stopService

      protected void stopService()
      Description copied from class: JdbcService
      Stop the service.

      This is called after before the connection is stopped

      Specified by:
      stopService in class JdbcService
    • handleInsert

      protected int handleInsert(String tableName, Connection conn, Map<String,String> obj) throws ServiceException
      Throws:
      ServiceException
    • addUpdatedMetadata

      protected AdaptrisMessage addUpdatedMetadata(int count, AdaptrisMessage msg)
    • getColumnBookendCharacter

      public Character getColumnBookendCharacter()
    • setColumnBookendCharacter

      public void setColumnBookendCharacter(Character c)
      Set the character used to bookend the column names.

      Sometimes you may need to bookend the column names with something like a ` because the names are in fact reserved words. Specify this as required.

      Parameters:
      c - default is null (or no book-ending).
    • withColumnBookend

      public <T extends JdbcMapInsert> T withColumnBookend(Character c)
    • columnBookend

      protected String columnBookend()
    • getRowsAffectedMetadataKey

      public String getRowsAffectedMetadataKey()
    • setRowsAffectedMetadataKey

      public void setRowsAffectedMetadataKey(String key)
      Set the metadata that will contain the number of rows inserted/updated by this service.
      Parameters:
      key - defaults to the empty string, and if not set, no metadata will be set.
      Since:
      3.9.0
    • withRowsAffectedMetadataKey

      public <T extends JdbcMapInsert> T withRowsAffectedMetadataKey(String s)