Package com.yahoo.gsheetjdbc.loader
Class DatabaseLoader
- java.lang.Object
-
- com.yahoo.gsheetjdbc.loader.DatabaseLoader
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DatabaseLoader extends Object implements Closeable
Loads data into an H2 database.
-
-
Constructor Summary
Constructors Constructor Description DatabaseLoader(String dbName)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ConnectiongetConnection()Fetches a JDBC connection to the underlying H2 database.voidrefreshTempTable(Table table, List<List<Object>> records)Loads a temporary table with a set of newly fetched records.voidswapTables(Table table)Swaps a newly loaded temporary table with the existing primary table.
-
-
-
Constructor Detail
-
DatabaseLoader
public DatabaseLoader(String dbName)
Constructor.- Parameters:
dbName- The name of the database to create for this loader.
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException
Fetches a JDBC connection to the underlying H2 database.- Returns:
- a JDBC connection
- Throws:
SQLException- on error
-
refreshTempTable
public void refreshTempTable(Table table, List<List<Object>> records) throws SQLException
Loads a temporary table with a set of newly fetched records.- Parameters:
table- The table to reload.records- The records to load in.- Throws:
SQLException- If an error occurs.
-
swapTables
public void swapTables(Table table) throws SQLException
Swaps a newly loaded temporary table with the existing primary table.- Parameters:
table- The table to swap.- Throws:
SQLException- If an error occurs.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-