Class ImportUtil
- java.lang.Object
-
- com.healthmarketscience.jackcess.util.ImportUtil
-
public class ImportUtil extends Object
Utility class for importing tables to an Access database from other sources. See theImportUtil.Builderfor convenient configuration of the import functionality. Note that most scenarios for customizing input data can be handled by implementing a customImportFilter.- Author:
- James Ahlborn
- Usage:
- General: This class is general use.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImportUtil.BuilderBuilder which simplifies configuration of an import operation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringimportFile(File f, Database db, String name, String delim)Copy a delimited text file into a new table in this database.static StringimportFile(File f, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable)Copy a delimited text file into a new table in this database.static StringimportFile(File f, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable, boolean header)Copy a delimited text file into a new table in this database.static StringimportFile(File f, Database db, String name, String delim, ImportFilter filter)Copy a delimited text file into a new table in this database.static StringimportReader(BufferedReader in, Database db, String name, String delim)Copy a delimited text file into a new table in this database.static StringimportReader(BufferedReader in, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable)Copy a delimited text file into a new (or optionally exixsting) table in this database.static StringimportReader(BufferedReader in, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable, boolean header)Copy a delimited text file into a new (or optionally exixsting) table in this database.static StringimportReader(BufferedReader in, Database db, String name, String delim, ImportFilter filter)Copy a delimited text file into a new table in this database.static StringimportReader(BufferedReader in, Database db, String name, String delim, ImportFilter filter, boolean useExistingTable)Copy a delimited text file into a new (or optionally exixsting) table in this database.static StringimportResultSet(ResultSet source, Database db, String name)Copy an existing JDBC ResultSet into a new table in this database.static StringimportResultSet(ResultSet source, Database db, String name, ImportFilter filter)Copy an existing JDBC ResultSet into a new table in this database.static StringimportResultSet(ResultSet source, Database db, String name, ImportFilter filter, boolean useExistingTable)Copy an existing JDBC ResultSet into a new (or optionally existing) table in this database.static List<ColumnBuilder>toColumns(ResultSetMetaData md)Returns a List of Column instances converted from the given ResultSetMetaData (this is the same method used by the variousimportResultSet()methods).
-
-
-
Method Detail
-
toColumns
public static List<ColumnBuilder> toColumns(ResultSetMetaData md) throws SQLException, IOException
Returns a List of Column instances converted from the given ResultSetMetaData (this is the same method used by the variousimportResultSet()methods).- Returns:
- a List of Columns
- Throws:
SQLExceptionIOException
-
importResultSet
public static String importResultSet(ResultSet source, Database db, String name) throws SQLException, IOException
Copy an existing JDBC ResultSet into a new table in this database.Equivalent to:
importResultSet(source, db, name, SimpleImportFilter.INSTANCE);- Parameters:
name- Name of the new table to createsource- ResultSet to copy from- Returns:
- the name of the copied table
- Throws:
SQLExceptionIOException- See Also:
importResultSet(ResultSet,Database,String,ImportFilter),ImportUtil.Builder
-
importResultSet
public static String importResultSet(ResultSet source, Database db, String name, ImportFilter filter) throws SQLException, IOException
Copy an existing JDBC ResultSet into a new table in this database.Equivalent to:
importResultSet(source, db, name, filter, false);- Parameters:
name- Name of the new table to createsource- ResultSet to copy fromfilter- valid import filter- Returns:
- the name of the imported table
- Throws:
SQLExceptionIOException- See Also:
importResultSet(ResultSet,Database,String,ImportFilter,boolean),ImportUtil.Builder
-
importResultSet
public static String importResultSet(ResultSet source, Database db, String name, ImportFilter filter, boolean useExistingTable) throws SQLException, IOException
Copy an existing JDBC ResultSet into a new (or optionally existing) table in this database.- Parameters:
name- Name of the new table to createsource- ResultSet to copy fromfilter- valid import filteruseExistingTable- iftrueuse current table if it already exists, otherwise, create new table with unique name- Returns:
- the name of the imported table
- Throws:
SQLExceptionIOException- See Also:
ImportUtil.Builder
-
importFile
public static String importFile(File f, Database db, String name, String delim) throws IOException
Copy a delimited text file into a new table in this database.Equivalent to:
importFile(f, name, db, delim, SimpleImportFilter.INSTANCE);- Parameters:
name- Name of the new table to createf- Source file to importdelim- Regular expression representing the delimiter string.- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
importFile(File,Database,String,String,ImportFilter),ImportUtil.Builder
-
importFile
public static String importFile(File f, Database db, String name, String delim, ImportFilter filter) throws IOException
Copy a delimited text file into a new table in this database.Equivalent to:
importFile(f, name, db, delim, "'", filter, false);- Parameters:
name- Name of the new table to createf- Source file to importdelim- Regular expression representing the delimiter string.filter- valid import filter- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
importReader(BufferedReader,Database,String,String,ImportFilter),ImportUtil.Builder
-
importFile
public static String importFile(File f, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable) throws IOException
Copy a delimited text file into a new table in this database.Equivalent to:
importReader(new BufferedReader(new FileReader(f)), db, name, delim, "'", filter, useExistingTable, true);- Parameters:
name- Name of the new table to createf- Source file to importdelim- Regular expression representing the delimiter string.quote- the quote characterfilter- valid import filteruseExistingTable- iftrueuse current table if it already exists, otherwise, create new table with unique name- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
importReader(BufferedReader,Database,String,String,ImportFilter,boolean),ImportUtil.Builder
-
importFile
public static String importFile(File f, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable, boolean header) throws IOException
Copy a delimited text file into a new table in this database.Equivalent to:
importReader(new BufferedReader(new FileReader(f)), db, name, delim, "'", filter, useExistingTable, header);- Parameters:
name- Name of the new table to createf- Source file to importdelim- Regular expression representing the delimiter string.quote- the quote characterfilter- valid import filteruseExistingTable- iftrueuse current table if it already exists, otherwise, create new table with unique nameheader- iffalsethe first line is not a header row, only valid if useExistingTable istrue- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
importReader(BufferedReader,Database,String,String,char,ImportFilter,boolean,boolean),ImportUtil.Builder
-
importReader
public static String importReader(BufferedReader in, Database db, String name, String delim) throws IOException
Copy a delimited text file into a new table in this database.Equivalent to:
importReader(in, db, name, delim, SimpleImportFilter.INSTANCE);- Parameters:
name- Name of the new table to createin- Source reader to importdelim- Regular expression representing the delimiter string.- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
importReader(BufferedReader,Database,String,String,ImportFilter),ImportUtil.Builder
-
importReader
public static String importReader(BufferedReader in, Database db, String name, String delim, ImportFilter filter) throws IOException
Copy a delimited text file into a new table in this database.Equivalent to:
importReader(in, db, name, delim, filter, false);- Parameters:
name- Name of the new table to createin- Source reader to importdelim- Regular expression representing the delimiter string.filter- valid import filter- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
importReader(BufferedReader,Database,String,String,ImportFilter,boolean),ImportUtil.Builder
-
importReader
public static String importReader(BufferedReader in, Database db, String name, String delim, ImportFilter filter, boolean useExistingTable) throws IOException
Copy a delimited text file into a new (or optionally exixsting) table in this database.Equivalent to:
importReader(in, db, name, delim, '"', filter, false);- Parameters:
name- Name of the new table to createin- Source reader to importdelim- Regular expression representing the delimiter string.filter- valid import filteruseExistingTable- iftrueuse current table if it already exists, otherwise, create new table with unique name- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
ImportUtil.Builder
-
importReader
public static String importReader(BufferedReader in, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable) throws IOException
Copy a delimited text file into a new (or optionally exixsting) table in this database.Equivalent to:
importReader(in, db, name, delim, '"', filter, useExistingTable, true);- Parameters:
name- Name of the new table to createin- Source reader to importdelim- Regular expression representing the delimiter string.quote- the quote characterfilter- valid import filteruseExistingTable- iftrueuse current table if it already exists, otherwise, create new table with unique name- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
ImportUtil.Builder
-
importReader
public static String importReader(BufferedReader in, Database db, String name, String delim, char quote, ImportFilter filter, boolean useExistingTable, boolean header) throws IOException
Copy a delimited text file into a new (or optionally exixsting) table in this database.- Parameters:
name- Name of the new table to createin- Source reader to importdelim- Regular expression representing the delimiter string.quote- the quote characterfilter- valid import filteruseExistingTable- iftrueuse current table if it already exists, otherwise, create new table with unique nameheader- iffalsethe first line is not a header row, only valid if useExistingTable istrue- Returns:
- the name of the imported table
- Throws:
IOException- See Also:
ImportUtil.Builder
-
-