|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.healthmarketscience.jackcess.Database
public class Database
An Access database.
There is optional support for large indexes (enabled by default). This optional support can be disabled via a few different means:
"false" will disable "large" index support across the jvmsetUseBigIndex(boolean) on a Database instance will override
any system property setting for "large" index support for all tables
subsequently created from that instancegetTable(String,boolean) can selectively
enable/disable "large" index support on a per-table basis (overriding
any Database or system property setting)
| Nested Class Summary | |
|---|---|
static class |
Database.FileFormat
Enum which indicates which version of Access created the database. |
| Field Summary | |
|---|---|
static String |
BROKEN_NIO_PROPERTY
(boolean) system property which can be used to indicate that the current vm has a poor nio implementation (specifically for FileChannel.transferFrom) |
static String |
CHARSET_PROPERTY_PREFIX
system property prefix which can be used to set the default Charset used for text data (full property includes the JetFormat version). |
static String |
COLUMN_ORDER_PROPERTY
system property which can be used to set the default sort order for table columns. |
static boolean |
DEFAULT_AUTO_SYNC
default value for the auto-sync value ( true). |
static Table.ColumnOrder |
DEFAULT_COLUMN_ORDER
the default sort order for table columns. |
static ErrorHandler |
DEFAULT_ERROR_HANDLER
default error handler used if none provided (just rethrows exception) |
static LinkResolver |
DEFAULT_LINK_RESOLVER
default link resolver used if none provided |
static String |
DEFAULT_RESOURCE_PATH
the default value for the resource path used to load classpath resources. |
static String |
FK_ENFORCE_PROPERTY
system property which can be used to set the default enforcement of foreign-key relationships. |
static String |
RESOURCE_PATH_PROPERTY
system property which can be used to set the path from which classpath resources are loaded (must end with a "/" if non-empty). |
static String |
TIMEZONE_PROPERTY
system property which can be used to set the default TimeZone used for date calculations. |
static String |
USE_BIG_INDEX_PROPERTY
(boolean) system property which can be used to disable the default big index support. |
| Method Summary | |
|---|---|
void |
close()
Close the database file (and any linked databases) |
String |
copyTable(String name,
ResultSet source)
Copy an existing JDBC ResultSet into a new table in this database |
String |
copyTable(String name,
ResultSet source,
ImportFilter filter)
Copy an existing JDBC ResultSet into a new table in this database |
static Database |
create(Database.FileFormat fileFormat,
File mdbFile)
Create a new Database for the given fileFormat |
static Database |
create(Database.FileFormat fileFormat,
File mdbFile,
boolean autoSync)
Create a new Database for the given fileFormat |
static Database |
create(Database.FileFormat fileFormat,
File mdbFile,
boolean autoSync,
Charset charset,
TimeZone timeZone)
Create a new Database for the given fileFormat |
static Database |
create(File mdbFile)
Create a new Access 2000 Database |
static Database |
create(File mdbFile,
boolean autoSync)
Create a new Access 2000 Database |
void |
createLinkedTable(String name,
String linkedDbName,
String linkedTableName)
Create a new table in this database |
void |
createTable(String name,
List<Column> columns)
Create a new table in this database |
void |
createTable(String name,
List<Column> columns,
List<IndexBuilder> indexes)
Create a new table in this database |
boolean |
defaultUseBigIndex()
Returns false if "big index support" has been disabled explicity
on the this Database or via a system property, true otherwise. |
boolean |
doUseBigIndex()
Whether or not big index support is enabled for tables. |
static String |
escapeIdentifier(String s)
|
void |
flush()
Flushes any current changes to the database file (and any linked databases) to disk. |
Table |
getAccessControlEntries()
|
Charset |
getCharset()
Gets currently configured Charset (always non- null). |
Table.ColumnOrder |
getColumnOrder()
Gets currently configured Table.ColumnOrder (always non-null). |
String |
getDatabasePassword()
|
PropertyMap |
getDatabaseProperties()
|
static Charset |
getDefaultCharset(JetFormat format)
Returns the default Charset for the given JetFormat. |
short |
getDefaultCodePage()
|
static Table.ColumnOrder |
getDefaultColumnOrder()
Returns the default Table.ColumnOrder. |
static boolean |
getDefaultEnforceForeignKeys()
Returns the default enforce foreign-keys policy. |
Column.SortOrder |
getDefaultSortOrder()
|
static TimeZone |
getDefaultTimeZone()
Returns the default TimeZone. |
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non- null). |
File |
getFile()
Returns the File underlying this Database |
Database.FileFormat |
getFileFormat()
Returns the FileFormat of this database (which may involve inspecting the database itself). |
JetFormat |
getFormat()
|
Map<String,Database> |
getLinkedDatabases()
Returns an unmodifiable view of the currently loaded linked databases, mapped from the linked database file name to the linked database. |
LinkResolver |
getLinkResolver()
Gets the currently configured LinkResolver (always non- null). |
PageChannel |
getPageChannel()
|
PropertyMaps |
getPropertiesForObject(int objectId)
|
List<Query> |
getQueries()
Finds all the queries in the database. |
List<Relationship> |
getRelationships(Table table1,
Table table2)
Finds all the relationships in the database between the given tables. |
PropertyMap |
getSummaryProperties()
|
Table |
getSystemCatalog()
|
Table |
getSystemComplexColumns()
|
Table |
getSystemTable(String tableName)
Returns a reference to any available table in this access database, including system tables. |
Set<String> |
getSystemTableNames()
|
Table |
getTable(int tableDefPageNumber)
|
Table |
getTable(String name)
|
Table |
getTable(String name,
boolean useBigIndex)
|
Set<String> |
getTableNames()
|
TimeZone |
getTimeZone()
Gets currently configured TimeZone (always non- null). |
PropertyMap |
getUserDefinedProperties()
|
String |
importFile(String name,
File f,
String delim)
Copy a delimited text file into a new table in this database |
String |
importFile(String name,
File f,
String delim,
ImportFilter filter)
Copy a delimited text file into a new table in this database |
String |
importReader(String name,
BufferedReader in,
String delim)
Copy a delimited text file into a new table in this database |
String |
importReader(String name,
BufferedReader in,
String delim,
ImportFilter filter)
Copy a delimited text file into a new table in this database |
boolean |
isEnforceForeignKeys()
Gets currently foreign-key enforcement policy. |
static boolean |
isReservedWord(String s)
|
Iterator<Table> |
iterator()
|
static Database |
open(File mdbFile)
Open an existing Database. |
static Database |
open(File mdbFile,
boolean readOnly)
Open an existing Database. |
static Database |
open(File mdbFile,
boolean readOnly,
boolean autoSync)
Open an existing Database. |
static Database |
open(File mdbFile,
boolean readOnly,
boolean autoSync,
Charset charset,
TimeZone timeZone)
Open an existing Database. |
static Database |
open(File mdbFile,
boolean readOnly,
boolean autoSync,
Charset charset,
TimeZone timeZone,
CodecProvider provider)
Open an existing Database. |
PropertyMaps |
readProperties(byte[] propsBytes,
int objectId)
|
void |
setCharset(Charset newCharset)
Sets a new Charset. |
void |
setColumnOrder(Table.ColumnOrder newColumnOrder)
Sets a new Table.ColumnOrder. |
void |
setEnforceForeignKeys(Boolean newEnforceForeignKeys)
Sets a new foreign-key enforcement policy. |
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler. |
void |
setLinkResolver(LinkResolver newLinkResolver)
Sets a new LinkResolver. |
void |
setTimeZone(TimeZone newTimeZone)
Sets a new TimeZone. |
void |
setUseBigIndex(boolean useBigIndex)
Set whether or not big index support is enabled for tables. |
String |
toString()
|
static void |
validateIdentifierName(String name,
int maxLength,
String identifierType)
Validates an identifier name. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final boolean DEFAULT_AUTO_SYNC
true). this is slower,
but leaves more chance of a useable database in the face of failures.
public static final String DEFAULT_RESOURCE_PATH
public static final Table.ColumnOrder DEFAULT_COLUMN_ORDER
public static final String USE_BIG_INDEX_PROPERTY
public static final String TIMEZONE_PROPERTY
public static final String CHARSET_PROPERTY_PREFIX
public static final String RESOURCE_PATH_PROPERTY
DEFAULT_RESOURCE_PATH if unspecified.
public static final String BROKEN_NIO_PROPERTY
public static final String COLUMN_ORDER_PROPERTY
Table.ColumnOrder enum
values.
public static final String FK_ENFORCE_PROPERTY
false.
public static final ErrorHandler DEFAULT_ERROR_HANDLER
public static final LinkResolver DEFAULT_LINK_RESOLVER
| Method Detail |
|---|
public static Database open(File mdbFile)
throws IOException
Equivalent to:
open(mdbFile, false);
mdbFile - File containing the database
IOExceptionopen(File,boolean),
for more flexible Database opening
public static Database open(File mdbFile,
boolean readOnly)
throws IOException
true, the file will be opened read-only.
Auto-syncing is enabled for the returned Database.
Equivalent to:
open(mdbFile, readOnly, DEFAULT_AUTO_SYNC);
mdbFile - File containing the databasereadOnly - iff true, force opening file in read-only
mode
IOExceptionopen(File,boolean,boolean),
for more flexible Database opening
public static Database open(File mdbFile,
boolean readOnly,
boolean autoSync)
throws IOException
true, the file will be opened read-only.
mdbFile - File containing the databasereadOnly - iff true, force opening file in read-only
modeautoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().
IOExceptionfor more flexible Database opening
public static Database open(File mdbFile,
boolean readOnly,
boolean autoSync,
Charset charset,
TimeZone timeZone)
throws IOException
true, the file will be opened read-only.
mdbFile - File containing the databasereadOnly - iff true, force opening file in read-only
modeautoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().charset - Charset to use, if null, uses defaulttimeZone - TimeZone to use, if null, uses default
IOExceptionfor more flexible Database opening
public static Database open(File mdbFile,
boolean readOnly,
boolean autoSync,
Charset charset,
TimeZone timeZone,
CodecProvider provider)
throws IOException
true, the file will be opened read-only.
mdbFile - File containing the databasereadOnly - iff true, force opening file in read-only
modeautoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().charset - Charset to use, if null, uses defaulttimeZone - TimeZone to use, if null, uses defaultprovider - CodecProvider for handling page encoding/decoding, may be
null if no special encoding is necessary
IOExceptionfor more flexible Database opening
public static Database create(File mdbFile)
throws IOException
Equivalent to:
create(FileFormat.V2000, mdbFile, DEFAULT_AUTO_SYNC);
mdbFile - Location to write the new database to. If this file
already exists, it will be overwritten.
IOExceptioncreate(File,boolean),
for more flexible Database creation
public static Database create(Database.FileFormat fileFormat,
File mdbFile)
throws IOException
Equivalent to:
create(fileFormat, mdbFile, DEFAULT_AUTO_SYNC);
fileFormat - version of new database.mdbFile - Location to write the new database to. If this file
already exists, it will be overwritten.
IOExceptioncreate(File,boolean),
for more flexible Database creation
public static Database create(File mdbFile,
boolean autoSync)
throws IOException
Equivalent to:
create(FileFormat.V2000, mdbFile, DEFAULT_AUTO_SYNC);
mdbFile - Location to write the new database to. If this file
already exists, it will be overwritten.autoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().
IOExceptionfor more flexible Database creation
public static Database create(Database.FileFormat fileFormat,
File mdbFile,
boolean autoSync)
throws IOException
fileFormat - version of new database.mdbFile - Location to write the new database to. If this file
already exists, it will be overwritten.autoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().
IOExceptionfor more flexible Database creation
public static Database create(Database.FileFormat fileFormat,
File mdbFile,
boolean autoSync,
Charset charset,
TimeZone timeZone)
throws IOException
fileFormat - version of new database.mdbFile - Location to write the new database to. If this file
already exists, it will be overwritten.autoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().charset - Charset to use, if null, uses defaulttimeZone - TimeZone to use, if null, uses default
IOExceptionfor more flexible Database creationpublic File getFile()
public PageChannel getPageChannel()
public JetFormat getFormat()
public Table getSystemCatalog()
public Table getAccessControlEntries()
throws IOException
IOException
public Table getSystemComplexColumns()
throws IOException
IOExceptionpublic boolean doUseBigIndex()
public void setUseBigIndex(boolean useBigIndex)
public ErrorHandler getErrorHandler()
null).
This will be used to handle all errors unless overridden at the Table or
Cursor level.
public void setErrorHandler(ErrorHandler newErrorHandler)
null, resets to the
DEFAULT_ERROR_HANDLER.
public LinkResolver getLinkResolver()
null).
This will be used to handle all linked database loading.
public void setLinkResolver(LinkResolver newLinkResolver)
null, resets to the
DEFAULT_LINK_RESOLVER.
public Map<String,Database> getLinkedDatabases()
public TimeZone getTimeZone()
null).
public void setTimeZone(TimeZone newTimeZone)
null, resets to the value returned by
getDefaultTimeZone().
public Charset getCharset()
null).
public void setCharset(Charset newCharset)
null, resets to the value returned by
getDefaultCharset(com.healthmarketscience.jackcess.JetFormat).
public Table.ColumnOrder getColumnOrder()
Table.ColumnOrder (always non-null).
public void setColumnOrder(Table.ColumnOrder newColumnOrder)
null, resets to the value
returned by getDefaultColumnOrder().
public boolean isEnforceForeignKeys()
public void setEnforceForeignKeys(Boolean newEnforceForeignKeys)
null, resets to
the value returned by isEnforceForeignKeys().
public Database.FileFormat getFileFormat()
throws IOException
IllegalStateException - if the file format cannot be determined
IOException
public Column.SortOrder getDefaultSortOrder()
throws IOException
IOException
public short getDefaultCodePage()
throws IOException
IOException
public PropertyMaps readProperties(byte[] propsBytes,
int objectId)
throws IOException
null result).
IOException
public Set<String> getTableNames()
throws IOException
IOException
public Set<String> getSystemTableNames()
throws IOException
getSystemTable(java.lang.String).
Extreme care should be taken if modifying these tables
directly!.
IOExceptionpublic Iterator<Table> iterator()
iterator in interface Iterable<Table>IllegalStateException - if an IOException is thrown by one of the
operations, the actual exception will be contained within
ConcurrentModificationException - if a table is added to the
database while an Iterator is in use.
public Table getTable(String name)
throws IOException
name - Table name
IOException
public Table getTable(String name,
boolean useBigIndex)
throws IOException
name - Table nameuseBigIndex - whether or not "big index support" should be enabled
for the table (this value will override any other
settings)
IOException
public Table getTable(int tableDefPageNumber)
throws IOException
tableDefPageNumber - the page number of a table definition
IOException
public void createTable(String name,
List<Column> columns)
throws IOException
name - Name of the table to createcolumns - List of Columns in the table
IOException
public void createTable(String name,
List<Column> columns,
List<IndexBuilder> indexes)
throws IOException
name - Name of the table to createcolumns - List of Columns in the tableindexes - List of IndexBuilders describing indexes for the table
IOException
public void createLinkedTable(String name,
String linkedDbName,
String linkedTableName)
throws IOException
name - Name of the table to create
IOException
public List<Relationship> getRelationships(Table table1,
Table table2)
throws IOException
IOException
public List<Query> getQueries()
throws IOException
IOException
public Table getSystemTable(String tableName)
throws IOException
Warning, this method is not designed for common use, only for the occassional time when access to a system table is necessary. Messing with system tables can strip the paint off your house and give your whole family a permanent, orange afro. You have been warned.
tableName - Table name, may be a system table
null if it doesn't exist
IOException
public PropertyMap getDatabaseProperties()
throws IOException
IOException
public PropertyMap getSummaryProperties()
throws IOException
IOException
public PropertyMap getUserDefinedProperties()
throws IOException
IOException
public PropertyMaps getPropertiesForObject(int objectId)
throws IOException
IOException
public String getDatabasePassword()
throws IOException
null if none set.
IOException
public String copyTable(String name,
ResultSet source)
throws SQLException,
IOException
name - Name of the new table to createsource - ResultSet to copy from
SQLException
IOExceptionImportUtil.importResultSet(ResultSet,Database,String)
public String copyTable(String name,
ResultSet source,
ImportFilter filter)
throws SQLException,
IOException
name - Name of the new table to createsource - ResultSet to copy fromfilter - valid import filter
SQLException
IOExceptionImportUtil.importResultSet(ResultSet,Database,String,ImportFilter)
public String importFile(String name,
File f,
String delim)
throws IOException
name - Name of the new table to createf - Source file to importdelim - Regular expression representing the delimiter string.
IOExceptionImportUtil.importFile(File,Database,String,String)
public String importFile(String name,
File f,
String delim,
ImportFilter filter)
throws IOException
name - Name of the new table to createf - Source file to importdelim - Regular expression representing the delimiter string.filter - valid import filter
IOExceptionImportUtil.importFile(File,Database,String,String,ImportFilter)
public String importReader(String name,
BufferedReader in,
String delim)
throws IOException
name - Name of the new table to createin - Source reader to importdelim - Regular expression representing the delimiter string.
IOExceptionImportUtil.importReader(BufferedReader,Database,String,String)
public String importReader(String name,
BufferedReader in,
String delim,
ImportFilter filter)
throws IOException
name - Name of the new table to createin - Source reader to importdelim - Regular expression representing the delimiter string.filter - valid import filter
IOExceptionImportUtil.importReader(BufferedReader,Database,String,String,ImportFilter)
public void flush()
throws IOException
flush in interface FlushableIOException
public void close()
throws IOException
close in interface CloseableIOExceptionpublic static String escapeIdentifier(String s)
public static boolean isReservedWord(String s)
true if the given string is a reserved word,
false otherwise
public static void validateIdentifierName(String name,
int maxLength,
String identifierType)
public String toString()
toString in class Objectpublic boolean defaultUseBigIndex()
false if "big index support" has been disabled explicity
on the this Database or via a system property, true otherwise.
public static TimeZone getDefaultTimeZone()
TimeZone.getDefault(), but can be
overridden using the system property "com.healthmarketscience.jackcess.timeZone".
public static Charset getDefaultCharset(JetFormat format)
"com.healthmarketscience.jackcess.charset.VERSION_3".
public static Table.ColumnOrder getDefaultColumnOrder()
DEFAULT_COLUMN_ORDER, but can be overridden using the system
property "com.healthmarketscience.jackcess.columnOrder".
public static boolean getDefaultEnforceForeignKeys()
false, but can be overridden using the system
property "com.healthmarketscience.jackcess.enforceForeignKeys".
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||