- java.lang.Object
-
- com.pervasive.datarush.operators.AbstractLogicalOperator
-
- com.pervasive.datarush.operators.CompositeOperator
-
- com.pervasive.datarush.operators.io.jdbc.JDBCOperator
-
- com.pervasive.datarush.operators.io.jdbc.AbstractWriteToJDBC
-
- All Implemented Interfaces:
ConnectionSettings
,LogicalOperator
- Direct Known Subclasses:
DeleteFromJDBC
,UpdateInJDBC
,WriteToJDBC
public abstract class AbstractWriteToJDBC extends JDBCOperator
Abstract implementation of a JDBC writer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractWriteToJDBC.AbstractWriteHelper
protected static class
AbstractWriteToJDBC.AbstractWriteToJDBCWorker
protected static class
AbstractWriteToJDBC.SqlWriteProperties
-
Field Summary
Fields Modifier and Type Field Description protected int
commitInterval
protected String
finalizeTableSQL
protected String
initializeTableSQL
protected RecordPort
input
protected int
isolationLevel
protected String[]
keyNames
protected Map<String,String>
renameMapping
-
Constructor Summary
Constructors Constructor Description AbstractWriteToJDBC()
AbstractWriteToJDBC(JDBCOperator other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
appendDelimited(StringBuilder command, String delimiter, List<String> fields, String fieldSuffix)
protected static String
buildDeleteStatement(String tableName, List<String> keyFields)
protected static String
buildInsertStatement(String tableName, List<String> fields)
protected static String
buildUpdateStatement(String tableName, List<String> nonKeyFields, List<String> keyFields)
protected String
createDropTableSQL()
protected String
createTruncateTableSQL()
int
getCommitInterval()
Retrieves the commit interval used by the JDBC driver.String
getFinalizeTableSQL()
Retrieves the SQL statement to execute after processing all the records.String
getInitializeTableSQL()
Retrieves the SQL statement to execute before processing any records.RecordPort
getInput()
Returns the input port.int
getIsolationLevel()
Retrieves the isolation level to use for the transactions.protected List<String>
getKeyNameList(List<String> fieldNameList)
String[]
getKeyNames()
Retrieves the field names (JDBC column names) to use as keys.Map<String,String>
getRenameMapping()
Returns the rename mapping.protected String
guessTableName()
void
setCommitInterval(int commitInterval)
Sets the commit interval used by the JDBC driver.void
setFinalizeTableSQL(String finalizeTableSQL)
Sets the SQL statement to execute after processing all the records.void
setInitializeTableSQL(String initializeTableSQL)
Sets the SQL statement to execute before processing any records.void
setIsolationLevel(int level)
Sets the isolation level to use for the transactions.void
setKeyNames(String[] keyNames)
Sets the field names (JDBC column names) to use as keys.void
setRenameMapping(Map<String,String> renameMapping)
Sets a rename mapping.-
Methods inherited from class com.pervasive.datarush.operators.io.jdbc.JDBCOperator
getConnectionFactory, getDriverName, getErrorAction, getHostNames, getJDBCConnector, getPassword, getSqlWarningLimit, getTableName, getUrl, getUser, setConnectionFactory, setDriverName, setErrorAction, setHostNames, setHostNames, setJDBCConnector, setPassword, setSqlWarningLimit, setTableName, setUrl, setUser
-
Methods inherited from class com.pervasive.datarush.operators.CompositeOperator
compose
-
Methods inherited from class com.pervasive.datarush.operators.AbstractLogicalOperator
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
-
-
-
-
Field Detail
-
input
protected final RecordPort input
-
keyNames
protected String[] keyNames
-
commitInterval
protected int commitInterval
-
isolationLevel
protected int isolationLevel
-
initializeTableSQL
protected String initializeTableSQL
-
finalizeTableSQL
protected String finalizeTableSQL
-
-
Constructor Detail
-
AbstractWriteToJDBC
public AbstractWriteToJDBC()
-
AbstractWriteToJDBC
public AbstractWriteToJDBC(JDBCOperator other)
-
-
Method Detail
-
getKeyNames
public String[] getKeyNames()
Retrieves the field names (JDBC column names) to use as keys.- Returns:
- the field names to use as keys
-
setKeyNames
public void setKeyNames(String[] keyNames)
Sets the field names (JDBC column names) to use as keys. Used when#outputMode
isOutputMode#UPDATE
orOutputMode#DELETE
.- Parameters:
keyNames
- the list of key name fields
-
getIsolationLevel
public int getIsolationLevel()
Retrieves the isolation level to use for the transactions.- Returns:
- the isolation level to use for the transactions
-
setIsolationLevel
public void setIsolationLevel(int level)
Sets the isolation level to use for the transactions. SeeConnection.setTransactionIsolation(int)
for isolation level explanations.- Parameters:
level
- the isolation level to use for the transactions
-
getCommitInterval
public int getCommitInterval()
Retrieves the commit interval used by the JDBC driver.- Returns:
- the commit interval used by the JDBC driver
-
setCommitInterval
public void setCommitInterval(int commitInterval)
Sets the commit interval used by the JDBC driver. This is the number of operations to execute between commit points.- Parameters:
commitInterval
- number of operations executed between commits
-
getInitializeTableSQL
public String getInitializeTableSQL()
Retrieves the SQL statement to execute before processing any records.- Returns:
- the SQL statement to execute before processing any records
-
setInitializeTableSQL
public void setInitializeTableSQL(String initializeTableSQL)
Sets the SQL statement to execute before processing any records. The most common use is initializing the table with aCREATE TABLE
statement.This statement is executed only once, regardless of
#partitionCount
.- Parameters:
initializeTableSQL
- the SQL statement to execute before processing any records
-
getFinalizeTableSQL
public String getFinalizeTableSQL()
Retrieves the SQL statement to execute after processing all the records.- Returns:
- the SQL statement to execute after processing all the records
-
setFinalizeTableSQL
public void setFinalizeTableSQL(String finalizeTableSQL)
Sets the SQL statement to execute after processing all the records. One example use is aCREATE INDEX
statement.This statement is executed only once, regardless of
#partitionCount
.- Parameters:
finalizeTableSQL
- the SQL statement to execute after processing all the records
-
getRenameMapping
public Map<String,String> getRenameMapping()
Returns the rename mapping.- Returns:
- the rename mapping.
-
setRenameMapping
public void setRenameMapping(Map<String,String> renameMapping)
Sets a rename mapping. This should be an ordered (i.e. LinkedHashMap) mapping of names. The keys in the map represent the original names in the record port. The values in the map represent column names in the table. Any columns that are not included in the mapping will be dropped.- Parameters:
renameMapping
- the mapping from old to new names.
-
getInput
public RecordPort getInput()
Returns the input port.- Returns:
- the input port
-
buildInsertStatement
protected static String buildInsertStatement(String tableName, List<String> fields)
-
buildUpdateStatement
protected static String buildUpdateStatement(String tableName, List<String> nonKeyFields, List<String> keyFields)
-
buildDeleteStatement
protected static String buildDeleteStatement(String tableName, List<String> keyFields)
-
appendDelimited
protected static void appendDelimited(StringBuilder command, String delimiter, List<String> fields, String fieldSuffix)
-
createTruncateTableSQL
protected String createTruncateTableSQL()
-
createDropTableSQL
protected String createDropTableSQL()
-
guessTableName
protected String guessTableName()
-
-