Package com.adaptris.core.services.jdbc
Class JdbcMapInsert
java.lang.Object
com.adaptris.core.ServiceImp
com.adaptris.core.jdbc.JdbcService
com.adaptris.core.services.jdbc.JdbcMapInsert
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,ConnectedService
,MessageEventGenerator
,Service
,StateManagedComponent
- Direct Known Subclasses:
JdbcMapUpsert
Base behaviour of inserting Objects directly into a db.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Handles simple type conversions for the fields in the map that needs to be inserted into the DB.class
protected static interface
static interface
-
Field Summary
Fields inherited from class com.adaptris.core.ServiceImp
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected AdaptrisMessage
addUpdatedMetadata
(int count, AdaptrisMessage msg) protected JdbcMapInsert.StatementParam
buildStatementParam
(String key, String value) protected void
Close the service.protected String
getTable()
protected int
handleInsert
(String tableName, Connection conn, Map<String, String> obj) protected void
protected void
void
Set the character used to bookend the column names.void
setFieldMappings
(KeyValuePairSet mappings) Set the converters for various fields in the map.void
Set the metadata that will contain the number of rows inserted/updated by this service.void
protected void
Start the service.protected void
Stop the service.protected String
table
(AdaptrisMessage msg) <T extends JdbcMapInsert>
T<T extends JdbcMapInsert>
T<T extends JdbcMapInsert>
T<T extends JdbcMapInsert>
TMethods inherited from class com.adaptris.core.jdbc.JdbcService
applyTimeout, closeService, createStatement, getConnection, getConnection, getStatementTimeout, initService, prepare, prepareStatement, prepareStatement, setConnection, setStatementTimeout, start, stop
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, enabled, getComments, getContinueOnFail, getEnabled, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setEnabled, setIsTrackingEndpoint, setUniqueId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
Methods inherited from interface com.adaptris.core.ConfigComment
getComments, setComments
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, doService, enabled, isBranching, setUniqueId
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
Constructor Details
-
JdbcMapInsert
public JdbcMapInsert()
-
-
Method Details
-
getTable
- Returns:
- the table
-
setTable
- Parameters:
s
- the table to insert on.
-
table
-
withTable
-
getFieldMappings
-
setFieldMappings
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 theJdbcMapInsert.BasicType
that we should attempt to convert to- See Also:
-
withMappings
-
buildStatementParam
-
closeJdbcService
protected void closeJdbcService()Description copied from class:JdbcService
Close the service.This is called before the connection is closed
- Specified by:
closeJdbcService
in classJdbcService
-
initJdbcService
- Specified by:
initJdbcService
in classJdbcService
- Throws:
CoreException
-
prepareService
- Specified by:
prepareService
in classJdbcService
- Throws:
CoreException
-
startService
Description copied from class:JdbcService
Start the service.This is called after the connection is started
- Specified by:
startService
in classJdbcService
- 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 classJdbcService
-
handleInsert
protected int handleInsert(String tableName, Connection conn, Map<String, String> obj) throws ServiceException- Throws:
ServiceException
-
addUpdatedMetadata
-
getColumnBookendCharacter
-
setColumnBookendCharacter
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
-
columnBookend
-
getRowsAffectedMetadataKey
-
setRowsAffectedMetadataKey
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
-