- 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 classAbstractWriteToJDBC.AbstractWriteHelperprotected static classAbstractWriteToJDBC.AbstractWriteToJDBCWorkerprotected static classAbstractWriteToJDBC.SqlWriteProperties
-
Field Summary
Fields Modifier and Type Field Description protected intcommitIntervalprotected StringfinalizeTableSQLprotected StringinitializeTableSQLprotected RecordPortinputprotected intisolationLevelprotected String[]keyNamesprotected 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 voidappendDelimited(StringBuilder command, String delimiter, List<String> fields, String fieldSuffix)protected static StringbuildDeleteStatement(String tableName, List<String> keyFields)protected static StringbuildInsertStatement(String tableName, List<String> fields)protected static StringbuildUpdateStatement(String tableName, List<String> nonKeyFields, List<String> keyFields)protected StringcreateDropTableSQL()protected StringcreateTruncateTableSQL()intgetCommitInterval()Retrieves the commit interval used by the JDBC driver.StringgetFinalizeTableSQL()Retrieves the SQL statement to execute after processing all the records.StringgetInitializeTableSQL()Retrieves the SQL statement to execute before processing any records.RecordPortgetInput()Returns the input port.intgetIsolationLevel()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 StringguessTableName()voidsetCommitInterval(int commitInterval)Sets the commit interval used by the JDBC driver.voidsetFinalizeTableSQL(String finalizeTableSQL)Sets the SQL statement to execute after processing all the records.voidsetInitializeTableSQL(String initializeTableSQL)Sets the SQL statement to execute before processing any records.voidsetIsolationLevel(int level)Sets the isolation level to use for the transactions.voidsetKeyNames(String[] keyNames)Sets the field names (JDBC column names) to use as keys.voidsetRenameMapping(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#outputModeisOutputMode#UPDATEorOutputMode#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 TABLEstatement.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 INDEXstatement.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()
-
-