|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jdbcimporter.engine.UpdateEngine
The UpdateEngine class executes an insert or update sql statement. It determines whether to use an insert or update sql statement by executing a select (based on the primary keys of the table). It will fail if the data to be imported does not contain a column that is part of the primary key.
Field Summary | |
protected static org.apache.commons.logging.Log |
LOG
The log for debug information. |
static java.lang.String |
PRIMARY_KEY_PROPERTY
The property on a column definition that will indicate the the column is a primary key (the value should be 'true'). |
static java.lang.String |
SELECT_POSTFIX_PROPERTY
The property on an entity definition whose value will be appended to the select statement. |
static java.lang.String |
UPDATE_EXPRESSION_PROPERTY
The property on a column definition whose value will be used as the update expression for that column (the value should contain the character '?'). |
Fields inherited from interface net.sourceforge.jdbcimporter.ImportEngine |
BATCH_SUCCESS_ROWS_UNKNOWN |
Constructor Summary | |
UpdateEngine()
|
Method Summary | |
void |
cleanup()
Cleans up any resources that the import engine used to import data for the current entity definition. |
void |
executeBatch()
Call executeBatch on the allocated statements. |
java.sql.Connection |
getConnection()
Returns the database connection to use for importing the row. |
protected java.util.List |
getDefinedPrimaryKeys()
Returns the list of primary keys defined in the import xml. |
protected java.util.List |
getPrimaryKeys(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Returns the list of primary keys from the DatabaseMeta. |
void |
importRow(ColumnValue[] values)
Imports the given set of values as a row into the database |
void |
init()
Initializes the import engine with the current entity definition. |
void |
setBatchMode(boolean flag)
Sets whether the import will use batch mode. |
void |
setConnection(java.sql.Connection con)
Sets the database connection to use for importing the row. |
void |
setEntityDef(ImportEntityDef entityDef)
Sets the entity definition to use for importing the row |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.commons.logging.Log LOG
public static final java.lang.String SELECT_POSTFIX_PROPERTY
public static final java.lang.String PRIMARY_KEY_PROPERTY
public static final java.lang.String UPDATE_EXPRESSION_PROPERTY
Constructor Detail |
public UpdateEngine()
Method Detail |
public void setConnection(java.sql.Connection con)
ImportEngine
setConnection
in interface ImportEngine
con
- database connectionImportEngine.setConnection(Connection)
public java.sql.Connection getConnection()
ImportEngine
getConnection
in interface ImportEngine
ImportEngine.getConnection()
public void setEntityDef(ImportEntityDef entityDef)
ImportEngine
setEntityDef
in interface ImportEngine
entityDef
- entity definitionImportEngine.setEntityDef(ImportEntityDef)
public void init() throws java.sql.SQLException
ImportEngine
init
in interface ImportEngine
java.sql.SQLException
- if a database error occurs during initializationImportEngine.init()
public void cleanup() throws java.sql.SQLException
ImportEngine
cleanup
in interface ImportEngine
java.sql.SQLException
- if a database error occurs during cleanupImportEngine.cleanup()
public void importRow(ColumnValue[] values) throws java.sql.SQLException, MalformedDataException
ImportEngine
importRow
in interface ImportEngine
values
- the column values for the row
java.sql.SQLException
- if a database error occurs during the import
MalformedDataException
ImportEngine.importRow(ColumnValue[])
protected java.util.List getDefinedPrimaryKeys()
protected java.util.List getPrimaryKeys(java.lang.String catalog, java.lang.String schema, java.lang.String table) throws java.sql.SQLException
catalog
- The catalogschema
- The schematable
- The table
java.sql.SQLException
public void setBatchMode(boolean flag)
ImportEngine
setBatchMode
in interface ImportEngine
flag
- true if the import will use batch modeImportEngine.setBatchMode(boolean)
public void executeBatch() throws java.sql.BatchUpdateException
ImportEngine
executeBatch
in interface ImportEngine
java.sql.BatchUpdateException
- If not all rows were imported then throw a BatchUpdateExceptionImportEngine.executeBatch()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |