javatools.database
Class Database.Inserter

java.lang.Object
  extended by javatools.database.Database.Inserter
All Implemented Interfaces:
java.io.Closeable
Enclosing class:
Database

public class Database.Inserter
extends java.lang.Object
implements java.io.Closeable

Represents a bulk loader


Constructor Summary
Database.Inserter(java.lang.String table)
          Creates a bulk loader
Database.Inserter(java.lang.String table, java.lang.Class<?>... columnTypes)
          Creates a bulk loader for a table with column types given by Java classes
Database.Inserter(java.lang.String table, int... columnTypes)
          Creates a bulk loader with column types from java.sql.Type
Database.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
 
Method Summary
 void close()
          Flushes and closes
 void flush()
          Flushes the 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 ****
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database.Inserter

public Database.Inserter(java.lang.String table)
                  throws java.sql.SQLException
Creates a bulk loader

Throws:
java.sql.SQLException

Database.Inserter

public Database.Inserter(java.lang.String table,
                         java.lang.Class<?>... columnTypes)
                  throws java.sql.SQLException
Creates a bulk loader for a table with column types given by Java classes

Throws:
java.sql.SQLException

Database.Inserter

public Database.Inserter(java.lang.String table,
                         int... columnTypes)
                  throws java.sql.SQLException
Creates a bulk loader with column types from java.sql.Type

Throws:
java.sql.SQLException

Database.Inserter

public Database.Inserter(java.lang.String table,
                         java.lang.String[] colnames,
                         java.lang.Class<?>[] coltypes)
                  throws java.sql.SQLException
Creates a bulk loader for specific coloumns of a table with column types given by their names and Java classes

Throws:
java.sql.SQLException
Method Detail

close

public void close()
Flushes and closes

Specified by:
close in interface java.io.Closeable

setBatchThreshold

public void setBatchThreshold(int size)
Inserter - Attribute Accessors ****


getBatchThreshold

public int getBatchThreshold()
returns the batch size set (i.e. after how many entries gathered the inserter should be flushed)


getTableName

public java.lang.String getTableName()
Returns the table name


getBatchSize

public int getBatchSize()
returns the number of entries gathered


numColumns

public int numColumns()
Returns the number of columns


insert

public void insert(java.util.List<java.lang.Object> row)
            throws java.sql.SQLException
Inserts a row

Throws:
java.sql.SQLException

insert

public void insert(java.lang.Object... values)
            throws java.sql.SQLException
Inserts a row

Throws:
java.sql.SQLException

flush

public void flush()
           throws java.sql.SQLException
Flushes the batch

Throws:
java.sql.SQLException