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