|
Elexis API documentationVersion 2.1.6 as of December 11 2011 | |||||||||
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
|
Field Summary | |
---|---|
static java.lang.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 boolean |
DEFAULT_AUTO_SYNC
default value for the auto-sync value ( true ). this is slower, but leaves more chance
of a useable database in the face of failures. |
static ErrorHandler |
DEFAULT_ERROR_HANDLER
default error handler used if none provided (just rethrows exception) |
static java.lang.String |
TIMEZONE_PROPERTY
system property which can be used to set the default TimeZone used for date calculations. |
static java.lang.String |
USE_BIG_INDEX_PROPERTY
system property which can be used to make big index support the default. |
Method Summary | |
---|---|
void |
close()
Close the database file |
java.lang.String |
copyTable(java.lang.String name,
java.sql.ResultSet source)
Copy an existing JDBC ResultSet into a new table in this database |
java.lang.String |
copyTable(java.lang.String name,
java.sql.ResultSet source,
ImportFilter filter)
Copy an existing JDBC ResultSet into a new table in this database |
static Database |
create(Database.FileFormat fileFormat,
java.io.File mdbFile)
Create a new Database for the given fileFormat Equivalent to: create(fileFormat, mdbFile, DEFAULT_AUTO_SYNC); |
static Database |
create(Database.FileFormat fileFormat,
java.io.File mdbFile,
boolean autoSync)
Create a new Database for the given fileFormat |
static Database |
create(Database.FileFormat fileFormat,
java.io.File mdbFile,
boolean autoSync,
java.nio.charset.Charset charset,
java.util.TimeZone timeZone)
Create a new Database for the given fileFormat |
static Database |
create(java.io.File mdbFile)
Create a new Access 2000 Database Equivalent to: create(FileFormat.V2000, mdbFile, DEFAULT_AUTO_SYNC); |
static Database |
create(java.io.File mdbFile,
boolean autoSync)
Create a new Access 2000 Database Equivalent to: create(FileFormat.V2000, mdbFile, DEFAULT_AUTO_SYNC); |
void |
createTable(java.lang.String name,
java.util.List<Column> columns)
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 java.lang.String |
escapeIdentifier(java.lang.String s)
|
void |
flush()
Flushes any current changes to the database file to disk. |
Table |
getAccessControlEntries()
|
java.nio.charset.Charset |
getCharset()
Gets currently configured Charset (always non- null ). |
static java.nio.charset.Charset |
getDefaultCharset(JetFormat format)
Returns the default Charset for the given JetFormat. |
static java.util.TimeZone |
getDefaultTimeZone()
Returns the default TimeZone. |
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non- null ). |
Database.FileFormat |
getFileFormat()
Returns the FileFormat of this database (which may involve inspecting the database itself). |
JetFormat |
getFormat()
|
PageChannel |
getPageChannel()
|
java.util.List<Query> |
getQueries()
Finds all the queries in the database. |
java.util.List<Relationship> |
getRelationships(Table table1,
Table table2)
Finds all the relationships in the database between the given tables. |
Table |
getSystemCatalog()
|
Table |
getSystemTable(java.lang.String tableName)
Returns a reference to any available table in this access database, including system tables. |
Table |
getTable(java.lang.String name)
|
Table |
getTable(java.lang.String name,
boolean useBigIndex)
|
java.util.Set<java.lang.String> |
getTableNames()
|
java.util.TimeZone |
getTimeZone()
Gets currently configured TimeZone (always non- null ). |
java.lang.String |
importFile(java.lang.String name,
java.io.File f,
java.lang.String delim)
Copy a delimited text file into a new table in this database |
java.lang.String |
importFile(java.lang.String name,
java.io.File f,
java.lang.String delim,
ImportFilter filter)
Copy a delimited text file into a new table in this database |
java.lang.String |
importReader(java.lang.String name,
java.io.BufferedReader in,
java.lang.String delim)
Copy a delimited text file into a new table in this database |
java.lang.String |
importReader(java.lang.String name,
java.io.BufferedReader in,
java.lang.String delim,
ImportFilter filter)
Copy a delimited text file into a new table in this database |
static boolean |
isReservedWord(java.lang.String s)
|
java.util.Iterator<Table> |
iterator()
|
static Database |
open(java.io.File mdbFile)
Open an existing Database. |
static Database |
open(java.io.File mdbFile,
boolean readOnly)
Open an existing Database. |
static Database |
open(java.io.File mdbFile,
boolean readOnly,
boolean autoSync)
Open an existing Database. |
static Database |
open(java.io.File mdbFile,
boolean readOnly,
boolean autoSync,
java.nio.charset.Charset charset,
java.util.TimeZone timeZone)
Open an existing Database. |
void |
setCharset(java.nio.charset.Charset newCharset)
Sets a new Charset. |
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler. |
void |
setTimeZone(java.util.TimeZone newTimeZone)
Sets a new TimeZone. |
void |
setUseBigIndex(boolean useBigIndex)
Set whether or not big index support is enabled for tables. |
java.lang.String |
toString()
|
static void |
validateIdentifierName(java.lang.String name,
int maxLength,
java.lang.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 java.lang.String USE_BIG_INDEX_PROPERTY
public static final java.lang.String TIMEZONE_PROPERTY
public static final java.lang.String CHARSET_PROPERTY_PREFIX
public static final ErrorHandler DEFAULT_ERROR_HANDLER
Method Detail |
---|
public static Database open(java.io.File mdbFile) throws java.io.IOException
Equivalent to: open(mdbFile, false);
mdbFile
- File containing the database
java.io.IOException
open(File,boolean)
public static Database open(java.io.File mdbFile, boolean readOnly) throws java.io.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
java.io.IOException
open(File,boolean,boolean)
public static Database open(java.io.File mdbFile, boolean readOnly, boolean autoSync) throws java.io.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.
java.io.IOException
public static Database open(java.io.File mdbFile, boolean readOnly, boolean autoSync, java.nio.charset.Charset charset, java.util.TimeZone timeZone) throws java.io.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.charset
- Charset to use, if null
, uses defaulttimeZone
- TimeZone to use, if null
, uses default
java.io.IOException
public static Database create(java.io.File mdbFile) throws java.io.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.
java.io.IOException
create(File,boolean)
public static Database create(Database.FileFormat fileFormat, java.io.File mdbFile) throws java.io.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.
java.io.IOException
create(File,boolean)
public static Database create(java.io.File mdbFile, boolean autoSync) throws java.io.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.
java.io.IOException
public static Database create(Database.FileFormat fileFormat, java.io.File mdbFile, boolean autoSync) throws java.io.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.
java.io.IOException
public static Database create(Database.FileFormat fileFormat, java.io.File mdbFile, boolean autoSync, java.nio.charset.Charset charset, java.util.TimeZone timeZone) throws java.io.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.charset
- Charset to use, if null
, uses defaulttimeZone
- TimeZone to use, if null
, uses default
java.io.IOException
public PageChannel getPageChannel()
public JetFormat getFormat()
public Table getSystemCatalog()
public Table getAccessControlEntries()
public 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 java.util.TimeZone getTimeZone()
null
).
public void setTimeZone(java.util.TimeZone newTimeZone)
null
, resets to the value returned by
getDefaultTimeZone()
.
public java.nio.charset.Charset getCharset()
null
).
public void setCharset(java.nio.charset.Charset newCharset)
null
, resets to the value returned by
getDefaultCharset(com.healthmarketscience.jackcess.JetFormat)
.
public Database.FileFormat getFileFormat()
java.lang.IllegalStateException
- if the file format cannot be determinedpublic java.util.Set<java.lang.String> getTableNames()
public java.util.Iterator<Table> iterator()
iterator
in interface java.lang.Iterable<Table>
java.lang.IllegalStateException
- if an IOException is thrown by one of the operations, the actual exception will
be contained within
java.util.ConcurrentModificationException
- if a table is added to the database while an Iterator is in use.public Table getTable(java.lang.String name) throws java.io.IOException
name
- Table name
java.io.IOException
public Table getTable(java.lang.String name, boolean useBigIndex) throws java.io.IOException
name
- Table nameuseBigIndex
- whether or not "big index support" should be enabled for the table (this value
will override any other settings)
java.io.IOException
public void createTable(java.lang.String name, java.util.List<Column> columns) throws java.io.IOException
name
- Name of the table to createcolumns
- List of Columns in the table
java.io.IOException
public java.util.List<Relationship> getRelationships(Table table1, Table table2) throws java.io.IOException
java.io.IOException
public java.util.List<Query> getQueries() throws java.io.IOException
java.io.IOException
public Table getSystemTable(java.lang.String tableName) throws java.io.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
java.io.IOException
public java.lang.String copyTable(java.lang.String name, java.sql.ResultSet source) throws java.sql.SQLException, java.io.IOException
name
- Name of the new table to createsource
- ResultSet to copy from
java.sql.SQLException
java.io.IOException
ImportUtil.importResultSet(ResultSet,Database,String)
public java.lang.String copyTable(java.lang.String name, java.sql.ResultSet source, ImportFilter filter) throws java.sql.SQLException, java.io.IOException
name
- Name of the new table to createsource
- ResultSet to copy fromfilter
- valid import filter
java.sql.SQLException
java.io.IOException
ImportUtil.importResultSet(ResultSet,Database,String,ImportFilter)
public java.lang.String importFile(java.lang.String name, java.io.File f, java.lang.String delim) throws java.io.IOException
name
- Name of the new table to createf
- Source file to importdelim
- Regular expression representing the delimiter string.
java.io.IOException
ImportUtil.importFile(File,Database,String,String)
public java.lang.String importFile(java.lang.String name, java.io.File f, java.lang.String delim, ImportFilter filter) throws java.io.IOException
name
- Name of the new table to createf
- Source file to importdelim
- Regular expression representing the delimiter string.filter
- valid import filter
java.io.IOException
ImportUtil.importFile(File,Database,String,String,ImportFilter)
public java.lang.String importReader(java.lang.String name, java.io.BufferedReader in, java.lang.String delim) throws java.io.IOException
name
- Name of the new table to createin
- Source reader to importdelim
- Regular expression representing the delimiter string.
java.io.IOException
ImportUtil.importReader(BufferedReader,Database,String,String)
public java.lang.String importReader(java.lang.String name, java.io.BufferedReader in, java.lang.String delim, ImportFilter filter) throws java.io.IOException
name
- Name of the new table to createin
- Source reader to importdelim
- Regular expression representing the delimiter string.filter
- valid import filter
java.io.IOException
ImportUtil.importReader(BufferedReader,Database,String,String,ImportFilter)
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
java.io.IOException
public static java.lang.String escapeIdentifier(java.lang.String s)
public static boolean isReservedWord(java.lang.String s)
true
if the given string is a reserved word, false
otherwisepublic static void validateIdentifierName(java.lang.String name, int maxLength, java.lang.String identifierType)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean defaultUseBigIndex()
false
if "big index support" has been disabled explicity on the this Database
or via a system property, true
otherwise.
public static java.util.TimeZone getDefaultTimeZone()
TimeZone.getDefault()
, but can be overridden using the system property
"com.healthmarketscience.jackcess.timeZone".
public static java.nio.charset.Charset getDefaultCharset(JetFormat format)
"com.healthmarketscience.jackcess.charset.VERSION_3"
.
|
Elexis API documentationVersion 2.1.6 as of December 11 2011 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |