public class Database extends Object implements VariableSpace, LoggingObjectInterface
Constructor and Description |
---|
Database(DatabaseMeta databaseMeta)
Deprecated.
Please specify the parent object so that we can see which object is initiating a database connection
|
Database(LoggingObjectInterface parentObject,
DatabaseMeta databaseMeta)
Construct a new Database Connection
|
Modifier and Type | Method and Description |
---|---|
boolean |
absolute(ResultSet rs,
int position) |
void |
afterLast(ResultSet rs) |
RowMetaAndData |
callProcedure(String[] arg,
String[] argdir,
int[] argtype,
String resultname,
int resulttype) |
void |
cancelQuery()
Cancel the open/running queries on the database connection
|
void |
cancelStatement(Statement statement)
Cancel an open/running SQL statement
|
boolean |
checkColumnExists(String columnname,
String tablename)
See if the column specified exists by reading
|
boolean |
checkIndexExists(String tableName,
String[] idx_fields)
Check if an index on certain fields in a table exists.
|
boolean |
checkIndexExists(String schemaName,
String tableName,
String[] idx_fields)
Check if an index on certain fields in a table exists.
|
boolean |
checkSequenceExists(String sequenceName)
Check whether the sequence exists, Oracle only!
|
boolean |
checkSequenceExists(String schemaName,
String sequenceName)
Check whether the sequence exists, Oracle only!
|
boolean |
checkTableExists(String tablename)
See if the table specified exists by reading
|
void |
cleanupLogRecords(LogTableCoreInterface logTable) |
void |
clearBatch(PreparedStatement preparedStatement) |
void |
clearInsertBatch()
Deprecated.
|
void |
closeConnectionOnly()
Only for unique connections usage, typically you use disconnect() to disconnect() from the database.
|
void |
closeInsert() |
void |
closeLookup() |
void |
closePreparedStatement(PreparedStatement ps) |
void |
closeProcedureStatement() |
void |
closeQuery(ResultSet res) |
void |
closeUpdate() |
void |
commit()
Perform a commit the connection if this is supported by the database
|
void |
commit(boolean force) |
void |
commitLog(boolean force,
LogTableCoreInterface logTable)
This methods may be removed in future.
|
void |
commitLog(LogTableCoreInterface logTable)
This methods may be removed in future.
|
void |
connect()
Open the database connection.
|
void |
connect(String partitionId)
Open the database connection.
|
void |
connect(String group,
String partitionId) |
void |
copyVariablesFrom(VariableSpace space)
Copy the variables from another space, without initializing with the defaults.
|
int |
countParameters(String sql) |
static KettleDatabaseBatchException |
createKettleDatabaseBatchException(String message,
SQLException ex) |
void |
disconnect()
Disconnect from the database and close all open prepared statements.
|
void |
emptyAndCommit(PreparedStatement ps,
boolean batch)
Close the passed prepared statement.
|
void |
emptyAndCommit(PreparedStatement ps,
boolean batch,
int batchCounter)
Close the prepared statement of the insert statement.
|
String |
environmentSubstitute(String aString)
Substitute the string using the current variable space.
|
String[] |
environmentSubstitute(String[] aString)
Replaces environment variables in an array of strings.
|
boolean |
equals(Object obj)
This implementation is NullPointerException subject, and
may not follow fundamental equals contract.
|
Result |
execStatement(String sql)
Execute an SQL statement on the database connection (has to be open)
|
Result |
execStatement(String rawsql,
RowMetaInterface params,
Object[] data) |
Result |
execStatements(String script)
Execute a series of SQL statements, separated by ;
We are already connected...
|
Result |
execStatements(String script,
RowMetaInterface params,
Object[] data)
Execute a series of SQL statements, separated by ;
We are already connected...
|
Result |
execStatementsFromFile(String filename,
boolean sendSinglestatement)
Execute an SQL statement inside a file on the database connection (has to be open)
|
void |
executeAndClearBatch(PreparedStatement preparedStatement) |
String |
fieldSubstitute(String aString,
RowMetaInterface rowMeta,
Object[] rowData)
Substitutes field values in
aString . |
void |
first(ResultSet rs) |
String |
getAlterTableStatement(String tableName,
RowMetaInterface fields,
String tk,
boolean use_autoinc,
String pk,
boolean semicolon) |
boolean |
getBooleanValueOfVariable(String variableName,
boolean defaultValue)
This method returns a boolean for the new variable check boxes.
|
String[] |
getCatalogs() |
Connection |
getConnection() |
String |
getConnectionGroup() |
String |
getContainerObjectId()
Gets the execution container (Carte/DI server/BI Server) object id.
|
int |
getCopy() |
String |
getCreateIndexStatement(String tablename,
String indexname,
String[] idx_fields,
boolean tk,
boolean unique,
boolean bitmap,
boolean semi_colon) |
String |
getCreateIndexStatement(String schemaname,
String tablename,
String indexname,
String[] idx_fields,
boolean tk,
boolean unique,
boolean bitmap,
boolean semi_colon) |
String |
getCreateSequenceStatement(String sequence,
long start_at,
long increment_by,
long max_value,
boolean semi_colon) |
String |
getCreateSequenceStatement(String schemaName,
String sequence,
long start_at,
long increment_by,
long max_value,
boolean semi_colon) |
String |
getCreateSequenceStatement(String sequence,
String start_at,
String increment_by,
String max_value,
boolean semi_colon) |
String |
getCreateSequenceStatement(String schemaName,
String sequenceName,
String start_at,
String increment_by,
String max_value,
boolean semi_colon) |
String |
getCreateTableStatement(String tableName,
RowMetaInterface fields,
String tk,
boolean use_autoinc,
String pk,
boolean semicolon)
Generates SQL
|
DatabaseMeta |
getDatabaseMeta() |
DatabaseMetaData |
getDatabaseMetaData() |
String |
getDDL(String tablename,
RowMetaInterface fields) |
String |
getDDL(String tablename,
RowMetaInterface fields,
String tk,
boolean use_autoinc,
String pk) |
String |
getDDL(String tableName,
RowMetaInterface fields,
String tk,
boolean use_autoinc,
String pk,
boolean semicolon) |
String |
getDDLCreationTable(String tableName,
RowMetaInterface fields)
Return SQL CREATION statement for a Table
|
String |
getDDLTruncateTable(String schema,
String tablename)
Return SQL TRUNCATE statement for a Table
|
String |
getFilename()
Gets the filename.
|
List<Object[]> |
getFirstRows(String table_name,
int limit) |
List<Object[]> |
getFirstRows(String table_name,
int limit,
ProgressMonitorListener monitor)
Get the first rows from a table (for preview)
|
RowMetaAndData |
getGeneratedKeys(PreparedStatement ps) |
String |
getInsertStatement(String tableName,
RowMetaInterface fields) |
String |
getInsertStatement(String schemaName,
String tableName,
RowMetaInterface fields) |
Object[] |
getLastLogDate(String logtable,
String name,
boolean job,
LogStatus status) |
String |
getLogChannelId()
Gets the log channel id.
|
LogLevel |
getLogLevel()
Gets the logging level of the log channel of this logging object.
|
Object[] |
getLookup() |
Object[] |
getLookup(boolean failOnMultipleResults) |
Object[] |
getLookup(PreparedStatement ps) |
Object[] |
getLookup(PreparedStatement ps,
boolean failOnMultipleResults) |
RowMeta |
getMetaFromRow(Object[] row,
ResultSetMetaData md) |
Long |
getNextSequenceValue(String sequenceName,
String keyfield) |
Long |
getNextSequenceValue(String schemaName,
String sequenceName,
String keyfield) |
Long |
getNextValue(Hashtable<String,Counter> counters,
String tableName,
String val_key) |
Long |
getNextValue(Hashtable<String,Counter> counters,
String schemaName,
String tableName,
String val_key) |
int |
getNrExecutedCommits() |
String |
getObjectCopy()
Gets a string identifying a copy in a series of steps.
|
ObjectId |
getObjectId()
Gets the object id in a repository.
|
String |
getObjectName()
Gets the object name.
|
ObjectRevision |
getObjectRevision()
Gets the objects revision in a repository.
|
LoggingObjectType |
getObjectType()
Gets the object type.
|
RowMetaAndData |
getOneRow(String sql)
Execute a query and return at most one row from the resultset
|
RowMetaAndData |
getOneRow(String sql,
RowMetaInterface param,
Object[] data) |
int |
getOpened() |
RowMetaInterface |
getParameterMetaData(PreparedStatement ps) |
RowMetaInterface |
getParameterMetaData(String sql,
RowMetaInterface inform,
Object[] data) |
LoggingObjectInterface |
getParent()
Gets the parent.
|
Object |
getParentObject() |
VariableSpace |
getParentVariableSpace()
Get the parent of the variable space.
|
String |
getPartitionId() |
PreparedStatement |
getPrepStatementInsert() |
PreparedStatement |
getPrepStatementLookup() |
PreparedStatement |
getPrepStatementUpdate() |
String[] |
getPrimaryKeyColumnNames(String tablename)
Return primary key column names ...
|
String[] |
getProcedures() |
RowMetaInterface |
getQueryFields(String sql,
boolean param) |
RowMetaInterface |
getQueryFields(String sql,
boolean param,
RowMetaInterface inform,
Object[] data) |
Date |
getRegistrationDate()
Stub
|
RepositoryDirectory |
getRepositoryDirectory()
Gets the repository directory.
|
RowMetaInterface |
getReturnRowMeta() |
Object[] |
getRow(ResultSet rs)
Get a row from the resultset.
|
Object[] |
getRow(ResultSet rs,
boolean lazyConversion)
Get a row from the resultset.
|
Object[] |
getRow(ResultSet rs,
ResultSetMetaData dummy,
RowMetaInterface rowInfo)
Get a row from the resultset.
|
List<Object[]> |
getRows(ResultSet rset,
int limit,
ProgressMonitorListener monitor)
Reads the result of a ResultSet into an ArrayList
|
List<Object[]> |
getRows(String sql,
int limit)
Reads the result of an SQL query into an ArrayList
|
List<Object[]> |
getRows(String sql,
int limit,
ProgressMonitorListener monitor)
Reads the result of an SQL query into an ArrayList
|
List<Object[]> |
getRows(String sql,
RowMetaInterface params,
Object[] data,
int fetch_mode,
boolean lazyConversion,
int limit,
ProgressMonitorListener monitor)
Reads the result of an SQL query into an ArrayList.
|
String[] |
getSchemas() |
String[] |
getSequences()
Return all sequence names from connection
|
String |
getSQLOutput(String schemaName,
String tableName,
RowMetaInterface fields,
Object[] r,
String dateFormat)
Return SQL statement (INSERT INTO TableName ...
|
Map<String,Collection<String>> |
getSynonymMap() |
Map<String,Collection<String>> |
getSynonymMap(String schemanamein) |
String[] |
getSynonyms() |
String[] |
getSynonyms(boolean includeSchema) |
String[] |
getSynonyms(String schemanamein,
boolean includeSchema) |
RowMetaInterface |
getTableFields(String tablename) |
Map<String,Collection<String>> |
getTableMap() |
Map<String,Collection<String>> |
getTableMap(String schemanamein) |
String[] |
getTablenames() |
String[] |
getTablenames(boolean includeSchema) |
String[] |
getTablenames(String schemanamein,
boolean includeSchema) |
String[] |
getTableTypes() |
boolean |
getUseBatchInsert(boolean batch) |
String |
getVariable(String variableName)
Get the value of a variable.
|
String |
getVariable(String variableName,
String defaultValue)
Get the value of a variable with a default in case the variable is not found.
|
Map<String,Collection<String>> |
getViewMap() |
Map<String,Collection<String>> |
getViewMap(String schemanamein) |
String[] |
getViews() |
String[] |
getViews(boolean includeSchema) |
String[] |
getViews(String schemanamein,
boolean includeSchema) |
void |
initializeVariablesFrom(VariableSpace parent)
Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()),
after this the "injected" variables should be inserted (injectVariables()).
|
void |
injectVariables(Map<String,String> prop)
Inject variables.
|
void |
insertFinished(boolean batch) |
void |
insertFinished(PreparedStatement ps,
boolean batch)
Deprecated.
use emptyAndCommit() instead (pass in the number of rows left in the batch)
|
void |
insertRow() |
void |
insertRow(boolean batch) |
void |
insertRow(PreparedStatement ps) |
boolean |
insertRow(PreparedStatement ps,
boolean batch)
Insert a row into the database using a prepared statement that has all values set.
|
boolean |
insertRow(PreparedStatement ps,
boolean batch,
boolean handleCommit)
Insert a row into the database using a prepared statement that has all values set.
|
void |
insertRow(String tableName,
RowMetaInterface fields,
Object[] data) |
void |
insertRow(String schemaName,
String tableName,
RowMetaInterface fields,
Object[] data) |
boolean |
isAutoCommit() |
boolean |
isForcingSeparateLogging() |
boolean |
isGatheringMetrics()
Gets the boolean value of whether or not this object is gathering kettle metrics during execution.
|
boolean |
isSystemTable(String table_name) |
String[] |
listVariables()
List the variables (not the values) that are currently in the variable space.
|
void |
lockTables(String[] tableNames)
Lock a tables in the database for write operations
|
void |
normalConnect(String partitionId)
Open the database connection.
|
ResultSet |
openQuery(PreparedStatement ps,
RowMetaInterface params,
Object[] data) |
ResultSet |
openQuery(String sql) |
ResultSet |
openQuery(String sql,
RowMetaInterface params,
Object[] data)
Open a query on the database with a set of parameters stored in a Kettle Row
|
ResultSet |
openQuery(String sql,
RowMetaInterface params,
Object[] data,
int fetch_mode) |
ResultSet |
openQuery(String sql,
RowMetaInterface params,
Object[] data,
int fetch_mode,
boolean lazyConversion) |
boolean |
prepareDelete(String table,
String[] codes,
String[] condition)
Prepare a delete statement by giving it the tablename, fields and conditions to work with.
|
boolean |
prepareDelete(String schemaName,
String tableName,
String[] codes,
String[] condition)
Prepare a delete statement by giving it the tablename, fields and conditions to work with.
|
void |
prepareInsert(RowMetaInterface rowMeta,
String tableName)
Prepare inserting values into a table, using the fields & values in a Row
|
void |
prepareInsert(RowMetaInterface rowMeta,
String schemaName,
String tableName)
Prepare inserting values into a table, using the fields & values in a Row
|
PreparedStatement |
prepareSQL(String sql)
Prepare a statement to be executed on the database.
|
PreparedStatement |
prepareSQL(String sql,
boolean returnKeys)
Prepare a statement to be executed on the database.
|
boolean |
prepareUpdate(String table,
String[] codes,
String[] condition,
String[] sets) |
boolean |
prepareUpdate(String schemaName,
String tableName,
String[] codes,
String[] condition,
String[] sets) |
void |
printSQLException(SQLException ex) |
boolean |
relative(ResultSet rs,
int rows) |
void |
releaseSavepoint(Savepoint savepoint) |
void |
rollback() |
void |
rollback(boolean force) |
void |
rollback(Savepoint savepoint) |
void |
setAutoCommit(boolean useAutoCommit) |
void |
setCommit(int commsize)
Specify after how many rows a commit needs to occur when inserting or updating values.
|
void |
setConnection(Connection connection)
Allows for the injection of a "life" connection, generated by a piece of software outside of Kettle.
|
void |
setConnectionGroup(String connectionGroup) |
void |
setContainerObjectId(String containerObjectId) |
void |
setCopy(int copy) |
void |
setForcingSeparateLogging(boolean forcingSeparateLogging)
This option will force the create of a separate logging channel even if the logging concerns identical objects with
identical names.
|
void |
setGatheringMetrics(boolean gatheringMetrics)
Enable of disable kettle metrics gathering during execution
|
void |
setLogLevel(LogLevel logLevel) |
void |
setLookup(String table,
String[] codes,
String[] condition,
String[] gets,
String[] rename,
String orderby) |
void |
setLookup(String tableName,
String[] codes,
String[] condition,
String[] gets,
String[] rename,
String orderby,
boolean checkForMultipleResults) |
void |
setLookup(String schema,
String table,
String[] codes,
String[] condition,
String[] gets,
String[] rename,
String orderby) |
void |
setLookup(String schemaName,
String tableName,
String[] codes,
String[] condition,
String[] gets,
String[] rename,
String orderby,
boolean checkForMultipleResults) |
void |
setNrExecutedCommits(int nrExecutedCommits) |
void |
setOpened(int opened) |
void |
setParentVariableSpace(VariableSpace parent)
Set the parent variable space
|
void |
setPartitionId(String partitionId) |
void |
setProcLookup(String proc,
String[] arg,
String[] argdir,
int[] argtype,
String returnvalue,
int returntype) |
void |
setProcValues(RowMetaInterface rowMeta,
Object[] data,
int[] argnrs,
String[] argdir,
boolean result) |
void |
setQueryLimit(int rows)
Set the maximum number of records to retrieve from a query.
|
Savepoint |
setSavepoint() |
Savepoint |
setSavepoint(String savePointName) |
void |
setValue(PreparedStatement ps,
ValueMetaInterface v,
Object object,
int pos) |
void |
setValues(RowMetaAndData row) |
void |
setValues(RowMetaAndData row,
PreparedStatement ps) |
void |
setValues(RowMetaInterface rowMeta,
Object[] data) |
void |
setValues(RowMetaInterface rowMeta,
Object[] data,
PreparedStatement ps) |
void |
setValues(RowMetaInterface rowMeta,
Object[] data,
PreparedStatement ps,
int ignoreThisValueIndex)
Sets the values of the preparedStatement pstmt.
|
void |
setValuesInsert(RowMetaAndData row) |
void |
setValuesInsert(RowMetaInterface rowMeta,
Object[] data) |
void |
setValuesLookup(RowMetaInterface rowMeta,
Object[] data) |
void |
setValuesUpdate(RowMetaInterface rowMeta,
Object[] data) |
void |
setVariable(String variableName,
String variableValue)
Sets a variable in the Kettle Variables list.
|
void |
shareVariablesWith(VariableSpace space)
Share a variable space from another variable space.
|
String |
toString() |
void |
truncateTable(String tablename) |
void |
truncateTable(String schema,
String tablename) |
void |
unlockTables(String[] tableNames)
Unlock certain tables in the database for write operations
|
void |
updateRow() |
void |
writeLogRecord(LogTableCoreInterface logTable,
LogStatus status,
Object subject,
Object parent) |
@Deprecated public Database(DatabaseMeta databaseMeta)
databaseMeta
- The Database Connection Info to construct the connection with.public Database(LoggingObjectInterface parentObject, DatabaseMeta databaseMeta)
databaseMeta
- The Database Connection Info to construct the connection with.public boolean equals(Object obj)
DatabaseMeta
equality.public void setConnection(Connection connection)
connection
- public Connection getConnection()
public void setQueryLimit(int rows)
rows
- public PreparedStatement getPrepStatementInsert()
public PreparedStatement getPrepStatementLookup()
public PreparedStatement getPrepStatementUpdate()
public void connect() throws KettleDatabaseException
KettleDatabaseException
- if something went wrong.public void connect(String partitionId) throws KettleDatabaseException
partitionId
- the partition ID in the cluster to connect to.KettleDatabaseException
- if something went wrong.public void connect(String group, String partitionId) throws KettleDatabaseException
KettleDatabaseException
public void normalConnect(String partitionId) throws KettleDatabaseException
partitionId
- the partition ID in the cluster to connect to.KettleDatabaseException
- if something went wrong.public void disconnect()
public void closeConnectionOnly() throws KettleDatabaseException
KettleDatabaseException
- in case there is an error during connection close.public void cancelQuery() throws KettleDatabaseException
KettleDatabaseException
public void cancelStatement(Statement statement) throws KettleDatabaseException
statement
- the statement to cancelKettleDatabaseException
public void setCommit(int commsize)
commsize
- The number of rows to wait before doing a commit on the connection.public void setAutoCommit(boolean useAutoCommit) throws KettleDatabaseException
KettleDatabaseException
public void commit() throws KettleDatabaseException
KettleDatabaseException
public void commit(boolean force) throws KettleDatabaseException
KettleDatabaseException
public void commitLog(LogTableCoreInterface logTable) throws KettleDatabaseException
logTable
- KettleDatabaseException
public void commitLog(boolean force, LogTableCoreInterface logTable) throws KettleDatabaseException
force
- logTable
- KettleDatabaseException
public void rollback() throws KettleDatabaseException
KettleDatabaseException
public void rollback(boolean force) throws KettleDatabaseException
KettleDatabaseException
public void prepareInsert(RowMetaInterface rowMeta, String tableName) throws KettleDatabaseException
rowMeta
- The row metadata to determine which values need to be insertedtable
- The name of the table in which we want to insert rowsKettleDatabaseException
- if something went wrong.public void prepareInsert(RowMetaInterface rowMeta, String schemaName, String tableName) throws KettleDatabaseException
rowMeta
- The metadata row to determine which values need to be insertedschemaName
- The name of the schema in which we want to insert rowstableName
- The name of the table in which we want to insert rowsKettleDatabaseException
- if something went wrong.public PreparedStatement prepareSQL(String sql) throws KettleDatabaseException
sql
- The SQL to be preparedKettleDatabaseException
public PreparedStatement prepareSQL(String sql, boolean returnKeys) throws KettleDatabaseException
sql
- The SQL to be preparedreturnKeys
- set to true if you want to return generated keys from an insert statementKettleDatabaseException
public void closeLookup() throws KettleDatabaseException
KettleDatabaseException
public void closePreparedStatement(PreparedStatement ps) throws KettleDatabaseException
KettleDatabaseException
public void closeInsert() throws KettleDatabaseException
KettleDatabaseException
public void closeUpdate() throws KettleDatabaseException
KettleDatabaseException
public void setValues(RowMetaInterface rowMeta, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public void setValues(RowMetaAndData row) throws KettleDatabaseException
KettleDatabaseException
public void setValuesInsert(RowMetaInterface rowMeta, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public void setValuesInsert(RowMetaAndData row) throws KettleDatabaseException
KettleDatabaseException
public void setValuesUpdate(RowMetaInterface rowMeta, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public void setValuesLookup(RowMetaInterface rowMeta, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public void setProcValues(RowMetaInterface rowMeta, Object[] data, int[] argnrs, String[] argdir, boolean result) throws KettleDatabaseException
KettleDatabaseException
public void setValue(PreparedStatement ps, ValueMetaInterface v, Object object, int pos) throws KettleDatabaseException
KettleDatabaseException
public void setValues(RowMetaAndData row, PreparedStatement ps) throws KettleDatabaseException
KettleDatabaseException
public void setValues(RowMetaInterface rowMeta, Object[] data, PreparedStatement ps) throws KettleDatabaseException
KettleDatabaseException
public void setValues(RowMetaInterface rowMeta, Object[] data, PreparedStatement ps, int ignoreThisValueIndex) throws KettleDatabaseException
rowMeta
- data
- KettleDatabaseException
public RowMetaAndData getGeneratedKeys(PreparedStatement ps) throws KettleDatabaseException
ps
- The prepared insert statement to useKettleDatabaseException
- in case something goes wrong retrieving the keys.public Long getNextSequenceValue(String sequenceName, String keyfield) throws KettleDatabaseException
KettleDatabaseException
public Long getNextSequenceValue(String schemaName, String sequenceName, String keyfield) throws KettleDatabaseException
KettleDatabaseException
public void insertRow(String tableName, RowMetaInterface fields, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public void insertRow(String schemaName, String tableName, RowMetaInterface fields, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public String getInsertStatement(String tableName, RowMetaInterface fields)
public String getInsertStatement(String schemaName, String tableName, RowMetaInterface fields)
public void insertRow() throws KettleDatabaseException
KettleDatabaseException
public void insertRow(boolean batch) throws KettleDatabaseException
KettleDatabaseException
public void updateRow() throws KettleDatabaseException
KettleDatabaseException
public void insertRow(PreparedStatement ps) throws KettleDatabaseException
KettleDatabaseException
public boolean insertRow(PreparedStatement ps, boolean batch) throws KettleDatabaseException
ps
- The prepared statementbatch
- True if you want to use batch inserts (size = commit size)KettleDatabaseException
public boolean getUseBatchInsert(boolean batch) throws KettleDatabaseException
KettleDatabaseException
public boolean insertRow(PreparedStatement ps, boolean batch, boolean handleCommit) throws KettleDatabaseException
ps
- The prepared statementbatch
- True if you want to use batch inserts (size = commit size)handleCommit
- True if you want to handle the commit here after the commit size (False e.g. in case the step handles
this, see TableOutput)KettleDatabaseException
@Deprecated public void clearInsertBatch() throws KettleDatabaseException
KettleDatabaseException
public void clearBatch(PreparedStatement preparedStatement) throws KettleDatabaseException
KettleDatabaseException
public void executeAndClearBatch(PreparedStatement preparedStatement) throws KettleDatabaseException
KettleDatabaseException
public void insertFinished(boolean batch) throws KettleDatabaseException
KettleDatabaseException
public void emptyAndCommit(PreparedStatement ps, boolean batch) throws KettleDatabaseException
ps
- batch
- KettleDatabaseException
public void emptyAndCommit(PreparedStatement ps, boolean batch, int batchCounter) throws KettleDatabaseException
ps
- The prepared statement to empty and close.batch
- true if you are using batch processingpsBatchCounter
- The number of rows on the batch queueKettleDatabaseException
public static KettleDatabaseBatchException createKettleDatabaseBatchException(String message, SQLException ex)
@Deprecated public void insertFinished(PreparedStatement ps, boolean batch) throws KettleDatabaseException
ps
- The prepared statement to empty and close.batch
- true if you are using batch processing (typically true for this method)psBatchCounter
- The number of rows on the batch queueKettleDatabaseException
public Result execStatement(String sql) throws KettleDatabaseException
sql
- The SQL to executeKettleDatabaseException
- in case anything goes wrong.public Result execStatement(String rawsql, RowMetaInterface params, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public Result execStatements(String script) throws KettleDatabaseException
script
- The SQL script to be executeKettleDatabaseException
- In case an error occurspublic Result execStatements(String script, RowMetaInterface params, Object[] data) throws KettleDatabaseException
script
- The SQL script to be executeparams
- Parameters Metadata
- Parameters valueKettleDatabaseException
- In case an error occurspublic ResultSet openQuery(String sql) throws KettleDatabaseException
KettleDatabaseException
public ResultSet openQuery(String sql, RowMetaInterface params, Object[] data) throws KettleDatabaseException
sql
- The SQL to launch with question marks (?) as placeholders for the parametersparams
- The parameters or null if no parameters are used.KettleDatabaseException
- when something goes wrong with the query.public ResultSet openQuery(String sql, RowMetaInterface params, Object[] data, int fetch_mode) throws KettleDatabaseException
KettleDatabaseException
public ResultSet openQuery(String sql, RowMetaInterface params, Object[] data, int fetch_mode, boolean lazyConversion) throws KettleDatabaseException
KettleDatabaseException
public ResultSet openQuery(PreparedStatement ps, RowMetaInterface params, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public RowMetaInterface getTableFields(String tablename) throws KettleDatabaseException
KettleDatabaseException
public RowMetaInterface getQueryFields(String sql, boolean param) throws KettleDatabaseException
KettleDatabaseException
public boolean checkTableExists(String tablename) throws KettleDatabaseException
tablename
- The name of the table to check.KettleDatabaseException
public boolean checkColumnExists(String columnname, String tablename) throws KettleDatabaseException
columnname
- The name of the column to check.tablename
- The name of the table to check.KettleDatabaseException
public boolean checkSequenceExists(String sequenceName) throws KettleDatabaseException
sequenceName
- The name of the sequenceKettleDatabaseException
public boolean checkSequenceExists(String schemaName, String sequenceName) throws KettleDatabaseException
sequenceName
- The name of the sequenceKettleDatabaseException
public boolean checkIndexExists(String tableName, String[] idx_fields) throws KettleDatabaseException
tableName
- The table on which the index is checkedidx_fields
- The fields on which the indexe is checkedKettleDatabaseException
public boolean checkIndexExists(String schemaName, String tableName, String[] idx_fields) throws KettleDatabaseException
tablename
- The table on which the index is checkedidx_fields
- The fields on which the indexe is checkedKettleDatabaseException
public String getCreateIndexStatement(String tablename, String indexname, String[] idx_fields, boolean tk, boolean unique, boolean bitmap, boolean semi_colon)
public String getCreateIndexStatement(String schemaname, String tablename, String indexname, String[] idx_fields, boolean tk, boolean unique, boolean bitmap, boolean semi_colon)
public String getCreateSequenceStatement(String sequence, long start_at, long increment_by, long max_value, boolean semi_colon)
public String getCreateSequenceStatement(String sequence, String start_at, String increment_by, String max_value, boolean semi_colon)
public String getCreateSequenceStatement(String schemaName, String sequence, long start_at, long increment_by, long max_value, boolean semi_colon)
public String getCreateSequenceStatement(String schemaName, String sequenceName, String start_at, String increment_by, String max_value, boolean semi_colon)
public RowMetaInterface getQueryFields(String sql, boolean param, RowMetaInterface inform, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public void closeQuery(ResultSet res) throws KettleDatabaseException
KettleDatabaseException
public boolean absolute(ResultSet rs, int position) throws KettleDatabaseException
KettleDatabaseException
public boolean relative(ResultSet rs, int rows) throws KettleDatabaseException
KettleDatabaseException
public void afterLast(ResultSet rs) throws KettleDatabaseException
KettleDatabaseException
public void first(ResultSet rs) throws KettleDatabaseException
KettleDatabaseException
public Object[] getRow(ResultSet rs) throws KettleDatabaseException
rs
- The resultset to get the row fromKettleDatabaseException
public Object[] getRow(ResultSet rs, boolean lazyConversion) throws KettleDatabaseException
rs
- The resultset to get the row fromlazyConversion
- set to true if strings need to have lazy conversion enabledKettleDatabaseException
public Object[] getRow(ResultSet rs, ResultSetMetaData dummy, RowMetaInterface rowInfo) throws KettleDatabaseException
rs
- The resultset to get the row fromKettleDatabaseException
public void printSQLException(SQLException ex)
public void setLookup(String table, String[] codes, String[] condition, String[] gets, String[] rename, String orderby) throws KettleDatabaseException
KettleDatabaseException
public void setLookup(String schema, String table, String[] codes, String[] condition, String[] gets, String[] rename, String orderby) throws KettleDatabaseException
KettleDatabaseException
public void setLookup(String tableName, String[] codes, String[] condition, String[] gets, String[] rename, String orderby, boolean checkForMultipleResults) throws KettleDatabaseException
KettleDatabaseException
public void setLookup(String schemaName, String tableName, String[] codes, String[] condition, String[] gets, String[] rename, String orderby, boolean checkForMultipleResults) throws KettleDatabaseException
KettleDatabaseException
public boolean prepareUpdate(String table, String[] codes, String[] condition, String[] sets)
public boolean prepareUpdate(String schemaName, String tableName, String[] codes, String[] condition, String[] sets)
public boolean prepareDelete(String table, String[] codes, String[] condition)
table
- The table-name to delete incodes
- condition
- public boolean prepareDelete(String schemaName, String tableName, String[] codes, String[] condition)
schemaName
- the schema-name to delete intableName
- The table-name to delete incodes
- condition
- public void setProcLookup(String proc, String[] arg, String[] argdir, int[] argtype, String returnvalue, int returntype) throws KettleDatabaseException
KettleDatabaseException
public Object[] getLookup() throws KettleDatabaseException
KettleDatabaseException
public Object[] getLookup(boolean failOnMultipleResults) throws KettleDatabaseException
KettleDatabaseException
public Object[] getLookup(PreparedStatement ps) throws KettleDatabaseException
KettleDatabaseException
public Object[] getLookup(PreparedStatement ps, boolean failOnMultipleResults) throws KettleDatabaseException
KettleDatabaseException
public DatabaseMetaData getDatabaseMetaData() throws KettleDatabaseException
KettleDatabaseException
public String getDDL(String tablename, RowMetaInterface fields) throws KettleDatabaseException
KettleDatabaseException
public String getDDL(String tablename, RowMetaInterface fields, String tk, boolean use_autoinc, String pk) throws KettleDatabaseException
KettleDatabaseException
public String getDDL(String tableName, RowMetaInterface fields, String tk, boolean use_autoinc, String pk, boolean semicolon) throws KettleDatabaseException
KettleDatabaseException
public String getCreateTableStatement(String tableName, RowMetaInterface fields, String tk, boolean use_autoinc, String pk, boolean semicolon)
tableName
- the table name or schema/table combination: this needs to be quoted properly in advance.fields
- the fieldstk
- the name of the technical key fielduse_autoinc
- true if we need to use auto-increment fields for a primary keypk
- the name of the primary/technical key fieldsemicolon
- append semicolon to the statementpkc
- primary key composite ( name of the key fields)public String getAlterTableStatement(String tableName, RowMetaInterface fields, String tk, boolean use_autoinc, String pk, boolean semicolon) throws KettleDatabaseException
KettleDatabaseException
public void truncateTable(String tablename) throws KettleDatabaseException
KettleDatabaseException
public void truncateTable(String schema, String tablename) throws KettleDatabaseException
KettleDatabaseException
public RowMetaAndData getOneRow(String sql) throws KettleDatabaseException
sql
- The SQL for the queryKettleDatabaseException
public RowMeta getMetaFromRow(Object[] row, ResultSetMetaData md) throws SQLException, KettleDatabaseException
SQLException
KettleDatabaseException
public RowMetaAndData getOneRow(String sql, RowMetaInterface param, Object[] data) throws KettleDatabaseException
KettleDatabaseException
public RowMetaInterface getParameterMetaData(PreparedStatement ps)
public int countParameters(String sql)
public RowMetaInterface getParameterMetaData(String sql, RowMetaInterface inform, Object[] data)
public void writeLogRecord(LogTableCoreInterface logTable, LogStatus status, Object subject, Object parent) throws KettleDatabaseException
KettleDatabaseException
public void cleanupLogRecords(LogTableCoreInterface logTable) throws KettleDatabaseException
KettleDatabaseException
public Object[] getLastLogDate(String logtable, String name, boolean job, LogStatus status) throws KettleDatabaseException
KettleDatabaseException
public Long getNextValue(Hashtable<String,Counter> counters, String tableName, String val_key) throws KettleDatabaseException
KettleDatabaseException
public Long getNextValue(Hashtable<String,Counter> counters, String schemaName, String tableName, String val_key) throws KettleDatabaseException
KettleDatabaseException
public boolean isSystemTable(String table_name)
public List<Object[]> getRows(String sql, int limit) throws KettleDatabaseException
sql
- The SQL to launchlimit
- <=0 means unlimited, otherwise this specifies the maximum number of rows read.KettleDatabaseException
- if something goes wrong.public List<Object[]> getRows(String sql, int limit, ProgressMonitorListener monitor) throws KettleDatabaseException
sql
- The SQL to launchlimit
- <=0 means unlimited, otherwise this specifies the maximum number of rows read.monitor
- The progress monitor to update while getting the rows.KettleDatabaseException
- if something goes wrong.public List<Object[]> getRows(String sql, RowMetaInterface params, Object[] data, int fetch_mode, boolean lazyConversion, int limit, ProgressMonitorListener monitor) throws KettleDatabaseException
sql
- The SQL to launchparams
- The types of any parameters to be passed to the querydata
- The values of any parameters to be passed to the queryfetch_mode
- The fetch mode for the query (ResultSet.FETCH_FORWARD, e.g.)lazyConversion
- Whether to perform lazy conversion of the valueslimit
- <=0 means unlimited, otherwise this specifies the maximum number of rows read.monitor
- The progress monitor to update while getting the rows.KettleDatabaseException
- if something goes wrong.public List<Object[]> getRows(ResultSet rset, int limit, ProgressMonitorListener monitor) throws KettleDatabaseException
rset
- the ResultSet to read outlimit
- <=0 means unlimited, otherwise this specifies the maximum number of rows read.monitor
- The progress monitor to update while getting the rows.KettleDatabaseException
- if something goes wrong.public List<Object[]> getFirstRows(String table_name, int limit) throws KettleDatabaseException
KettleDatabaseException
public List<Object[]> getFirstRows(String table_name, int limit, ProgressMonitorListener monitor) throws KettleDatabaseException
table_name
- The table name (or schema/table combination): this needs to be quoted properlylimit
- limit <=0 means unlimited, otherwise this specifies the maximum number of rows read.monitor
- The progress monitor to update while getting the rows.KettleDatabaseException
- in case something goes wrongpublic RowMetaInterface getReturnRowMeta()
public String[] getTableTypes() throws KettleDatabaseException
KettleDatabaseException
public String[] getTablenames() throws KettleDatabaseException
KettleDatabaseException
public String[] getTablenames(boolean includeSchema) throws KettleDatabaseException
KettleDatabaseException
public String[] getTablenames(String schemanamein, boolean includeSchema) throws KettleDatabaseException
KettleDatabaseException
public Map<String,Collection<String>> getTableMap() throws KettleDatabaseException
KettleDatabaseException
public Map<String,Collection<String>> getTableMap(String schemanamein) throws KettleDatabaseException
KettleDatabaseException
public String[] getViews() throws KettleDatabaseException
KettleDatabaseException
public String[] getViews(boolean includeSchema) throws KettleDatabaseException
KettleDatabaseException
public String[] getViews(String schemanamein, boolean includeSchema) throws KettleDatabaseException
KettleDatabaseException
public Map<String,Collection<String>> getViewMap() throws KettleDatabaseException
KettleDatabaseException
public Map<String,Collection<String>> getViewMap(String schemanamein) throws KettleDatabaseException
KettleDatabaseException
public String[] getSynonyms() throws KettleDatabaseException
KettleDatabaseException
public String[] getSynonyms(boolean includeSchema) throws KettleDatabaseException
KettleDatabaseException
public String[] getSynonyms(String schemanamein, boolean includeSchema) throws KettleDatabaseException
KettleDatabaseException
public Map<String,Collection<String>> getSynonymMap() throws KettleDatabaseException
KettleDatabaseException
public Map<String,Collection<String>> getSynonymMap(String schemanamein) throws KettleDatabaseException
KettleDatabaseException
public String[] getSchemas() throws KettleDatabaseException
KettleDatabaseException
public String[] getCatalogs() throws KettleDatabaseException
KettleDatabaseException
public String[] getProcedures() throws KettleDatabaseException
KettleDatabaseException
public boolean isAutoCommit()
public DatabaseMeta getDatabaseMeta()
public void lockTables(String[] tableNames) throws KettleDatabaseException
tableNames
- The tables to lock. These need to be the appropriately quoted fully qualified (schema+table) names.KettleDatabaseException
public void unlockTables(String[] tableNames) throws KettleDatabaseException
tableNames
- The tables to unlockKettleDatabaseException
public int getOpened()
public void setOpened(int opened)
opened
- the opened to setpublic String getConnectionGroup()
public void setConnectionGroup(String connectionGroup)
connectionGroup
- the connectionGroup to setpublic String getPartitionId()
public void setPartitionId(String partitionId)
partitionId
- the partitionId to setpublic int getCopy()
public void setCopy(int copy)
copy
- the copy to setpublic void copyVariablesFrom(VariableSpace space)
VariableSpace
copyVariablesFrom
in interface VariableSpace
space
- the space to copy the variables from.public String environmentSubstitute(String aString)
VariableSpace
environmentSubstitute
in interface VariableSpace
aString
- The string to substitute.public String[] environmentSubstitute(String[] aString)
VariableSpace
environmentSubstitute
in interface VariableSpace
aString
- The array of strings that wants its variables to be replaced.public String fieldSubstitute(String aString, RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException
VariableSpace
aString
. Field values are of the form "?{fieldSubstitute
in interface VariableSpace
aString
- the string on which to apply the substitution.rowMeta
- The row metadata to use.rowData
- The row data to useKettleValueException
- In case there is a String conversion errorpublic VariableSpace getParentVariableSpace()
VariableSpace
getParentVariableSpace
in interface VariableSpace
public void setParentVariableSpace(VariableSpace parent)
VariableSpace
setParentVariableSpace
in interface VariableSpace
parent
- The parent variable space to setpublic String getVariable(String variableName, String defaultValue)
VariableSpace
getVariable
in interface VariableSpace
variableName
- The name of the variabledefaultValue
- The default value in case the variable could not be foundpublic String getVariable(String variableName)
VariableSpace
getVariable
in interface VariableSpace
variableName
- The name of the variablepublic boolean getBooleanValueOfVariable(String variableName, boolean defaultValue)
VariableSpace
getBooleanValueOfVariable
in interface VariableSpace
variableName
- The variable to look up.defaultValue
- The default value to return.static method ValueMeta.convertStringToBoolean()
public void initializeVariablesFrom(VariableSpace parent)
VariableSpace
initializeVariablesFrom
in interface VariableSpace
parent
- the parent to start from, or null if root.public String[] listVariables()
VariableSpace
listVariables
in interface VariableSpace
public void setVariable(String variableName, String variableValue)
VariableSpace
setVariable
in interface VariableSpace
variableName
- The name of the variable to setvariableValue
- The value of the variable to set. If the variableValue is null, the variable is cleared from the list.public void shareVariablesWith(VariableSpace space)
VariableSpace
shareVariablesWith
in interface VariableSpace
space
- Variable space to be shared.public void injectVariables(Map<String,String> prop)
VariableSpace
injectVariables
in interface VariableSpace
prop
- Properties object containing key-value pairs.public RowMetaAndData callProcedure(String[] arg, String[] argdir, int[] argtype, String resultname, int resulttype) throws KettleDatabaseException
KettleDatabaseException
public void closeProcedureStatement() throws KettleDatabaseException
KettleDatabaseException
public String getDDLCreationTable(String tableName, RowMetaInterface fields) throws KettleDatabaseException
tableName
- The table to createKettleDatabaseException
public String getDDLTruncateTable(String schema, String tablename) throws KettleDatabaseException
schema
- The schematableNameWithSchema
- The table to createKettleDatabaseException
public String getSQLOutput(String schemaName, String tableName, RowMetaInterface fields, Object[] r, String dateFormat) throws KettleDatabaseException
schemaName
- tableName The schematableName
- fields
- dateFormat
- date format of fieldKettleDatabaseException
public Savepoint setSavepoint() throws KettleDatabaseException
KettleDatabaseException
public Savepoint setSavepoint(String savePointName) throws KettleDatabaseException
KettleDatabaseException
public void releaseSavepoint(Savepoint savepoint) throws KettleDatabaseException
KettleDatabaseException
public void rollback(Savepoint savepoint) throws KettleDatabaseException
KettleDatabaseException
public Object getParentObject()
public String[] getPrimaryKeyColumnNames(String tablename) throws KettleDatabaseException
tablename
- KettleDatabaseException
public String[] getSequences() throws KettleDatabaseException
KettleDatabaseException
public String getFilename()
LoggingObjectInterface
getFilename
in interface LoggingObjectInterface
public String getLogChannelId()
LoggingObjectInterface
getLogChannelId
in interface LoggingObjectInterface
public String getObjectName()
LoggingObjectInterface
getObjectName
in interface LoggingObjectInterface
public String getObjectCopy()
LoggingObjectInterface
getObjectCopy
in interface LoggingObjectInterface
public ObjectId getObjectId()
LoggingObjectInterface
getObjectId
in interface LoggingObjectInterface
public ObjectRevision getObjectRevision()
LoggingObjectInterface
getObjectRevision
in interface LoggingObjectInterface
public LoggingObjectType getObjectType()
LoggingObjectInterface
getObjectType
in interface LoggingObjectInterface
public LoggingObjectInterface getParent()
LoggingObjectInterface
getParent
in interface LoggingObjectInterface
public RepositoryDirectory getRepositoryDirectory()
LoggingObjectInterface
getRepositoryDirectory
in interface LoggingObjectInterface
public LogLevel getLogLevel()
LoggingObjectInterface
getLogLevel
in interface LoggingObjectInterface
public void setLogLevel(LogLevel logLevel)
public String getContainerObjectId()
LoggingObjectInterface
getContainerObjectId
in interface LoggingObjectInterface
public void setContainerObjectId(String containerObjectId)
containerObjectId
- the execution container Object id to setpublic Date getRegistrationDate()
getRegistrationDate
in interface LoggingObjectInterface
public int getNrExecutedCommits()
public void setNrExecutedCommits(int nrExecutedCommits)
nrExecutedCommits
- the nrExecutedCommits to setpublic Result execStatementsFromFile(String filename, boolean sendSinglestatement) throws KettleException
sql
- The file that contains SQL to executeKettleDatabaseException
- in case anything goes wrong.KettleException
public boolean isGatheringMetrics()
LoggingObjectInterface
isGatheringMetrics
in interface LoggingObjectInterface
public void setGatheringMetrics(boolean gatheringMetrics)
LoggingObjectInterface
setGatheringMetrics
in interface LoggingObjectInterface
gatheringMetrics
- set to true to enable metrics gathering during execution.public boolean isForcingSeparateLogging()
isForcingSeparateLogging
in interface LoggingObjectInterface
public void setForcingSeparateLogging(boolean forcingSeparateLogging)
LoggingObjectInterface
setForcingSeparateLogging
in interface LoggingObjectInterface
forcingSeparateLogging
- Set to true to force separate logging