public class Database.Inserter extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected SQLType[] |
columnTypes
Column types
|
protected String |
tableName
Table where the data will be inserted
|
protected List<List<Object>> |
values
the currently cached values
|
| Constructor and Description |
|---|
Inserter(String table)
Creates a bulk loader
|
Inserter(String table,
Class<?>... columnTypes)
Creates a bulk loader for a table with column types given by Java classes
|
Inserter(String table,
int... columnTypes)
Creates a bulk loader with column types from java.sql.Type
|
Inserter(String table,
String[] colnames,
Class<?>[] coltypes)
Creates a bulk loader for specific coloumns of a table with column types given by their names and Java classes
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Flushes and closes
|
protected void |
finalize() |
void |
flush()
Flushes the batch
|
protected void |
flush(List<List<Object>> batch) |
int |
getBatchSize()
returns the number of entries gathered
|
int |
getBatchThreshold()
returns the batch size set (i.e.
|
String |
getTableName()
Returns the table name
|
void |
insert(List<Object> row)
Inserts a row
|
void |
insert(Object... values)
Inserts a row
|
int |
numColumns()
Returns the number of columns
|
void |
setBatchThreshold(int size)
Inserter - Attribute Accessors ****
|
protected void |
setTargetTable(String table)
Sets the target table into which values shall be inserted
|
protected void |
setTargetTable(String table,
Class<?>... columnTypes)
Sets the target table into which values shall be inserted
with the types of the table columns explicitly given
|
protected void |
setTargetTable(String table,
int... columnTypes)
Sets the target table into which values shall be inserted
with the types of the table columns explicitly given (as java.sql.Type types)
|
protected void |
setTargetTable(String table,
String[] colnames,
Class<?>[] coltypes) |
protected String tableName
protected SQLType[] columnTypes
public Inserter(String table) throws SQLException
SQLExceptionpublic Inserter(String table, Class<?>... columnTypes) throws SQLException
SQLExceptionpublic Inserter(String table, int... columnTypes) throws SQLException
SQLExceptionpublic Inserter(String table, String[] colnames, Class<?>[] coltypes) throws SQLException
SQLExceptionpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void setBatchThreshold(int size)
public int getBatchThreshold()
public String getTableName()
public int getBatchSize()
public int numColumns()
protected void setTargetTable(String table) throws SQLException
SQLExceptionprotected void setTargetTable(String table, Class<?>... columnTypes) throws SQLException
SQLExceptionprotected void setTargetTable(String table, int... columnTypes) throws SQLException
SQLExceptionprotected void setTargetTable(String table, String[] colnames, Class<?>[] coltypes) throws SQLException
SQLExceptionpublic void insert(List<Object> row) throws SQLException
SQLExceptionpublic void insert(Object... values) throws SQLException
SQLExceptionpublic void flush()
throws SQLException
SQLExceptionprotected void flush(List<List<Object>> batch) throws SQLException
SQLExceptionCopyright © 2018. All rights reserved.