public interface BulkInserter
Modifier and Type | Method and Description |
---|---|
void |
close()
after inserting all rows please call this method to finish copying process .
|
void |
copyTable(SqlManager sourceSql,
java.lang.String sourceTable,
java.lang.String destTable,
java.lang.String where)
Call this method to copy data between tables with identical structures
( Same number of columns with the same name and same type .
|
void |
insertRow(java.util.HashMap<java.lang.String,java.io.Serializable> row)
Call this method to bulk insert data into table .
|
void |
prepareInsert(java.lang.String table,
java.util.HashMap<java.lang.String,java.io.Serializable> columnNames)
Call this method to prepare for bulk insert data into table
|
void copyTable(SqlManager sourceSql, java.lang.String sourceTable, java.lang.String destTable, java.lang.String where) throws java.sql.SQLException
sourceSql
- sqlmanger taken from the same database as sourceTable - will be used to select table metatada and datasourceTable
- source table namedestTable
- desctination table namewhere
- optional where condition that can be used to move on subset of rows from sourceTable to destTable .
You can use bind variables in where but you have to make sure they are visible to the sourceSql as
framework will execute select statement from source table using sourceSqljava.sql.SQLException
void prepareInsert(java.lang.String table, java.util.HashMap<java.lang.String,java.io.Serializable> columnNames) throws java.sql.SQLException
table
- target column namecolumnNames
- a HashMap with keys equals to column names you want to insert;
you can use this HashMap later on to pass data in insertRow()java.sql.SQLException
void insertRow(java.util.HashMap<java.lang.String,java.io.Serializable> row) throws java.sql.SQLException
row
- is a HashMap that should contain the row data you want to insert where
data should be passed as pairs of ColumnName:Value where ColumnName should be the same
column name you declared in the prepareInsert method . You should fetch data from the soruce table
using hashtable ( instead of using class insetance variables . You need to call setBindsTable(row)
on the source sql manager to let it know you use hashtable instead of bind class).java.sql.SQLException
void close() throws java.sql.SQLException
java.sql.SQLException