|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Database
An Access database instance. A new instance can be instantiated by opening
an existing database file (DatabaseBuilder.open(File)
) or creating
a new database file (DatabaseBuilder.create(Database.FileFormat,File)
) (for
more advanced opening/creating use DatabaseBuilder
). Once a
Database has been opened, you can interact with the data via the relevant
Table
. When a Database instance is no longer useful, it should
always be closed (close()
) to avoid corruption.
Nested Class Summary | |
---|---|
static class |
Database.FileFormat
Enum which indicates which version of Access created the database. |
Field Summary | |
---|---|
static String |
ALLOW_AUTONUM_INSERT_PROPERTY
system property which can be used to set the default allow auto number insert policy. |
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 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. |
Method Summary | |
---|---|
void |
close()
Close the database file (and any linked databases). |
void |
createLinkedTable(String name,
String linkedDbName,
String linkedTableName)
Create a new table in this database |
void |
flush()
Flushes any current changes to the database file (and any linked databases) to disk. |
Charset |
getCharset()
Gets currently configured Charset (always non- null ). |
Table.ColumnOrder |
getColumnOrder()
Gets currently configured Table.ColumnOrder (always non-null ). |
ColumnValidatorFactory |
getColumnValidatorFactory()
Gets currently configured ColumnValidatorFactory (always non- null ). |
String |
getDatabasePassword()
|
PropertyMap |
getDatabaseProperties()
|
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). |
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 ). |
List<Query> |
getQueries()
Finds all the queries in the database. |
List<Relationship> |
getRelationships()
Finds all the relationships in the database in non-system tables. |
List<Relationship> |
getRelationships(Table table)
Finds all the relationships in the database for the given table. |
List<Relationship> |
getRelationships(Table table1,
Table table2)
Finds all the relationships in the database between the given tables. |
PropertyMap |
getSummaryProperties()
|
List<Relationship> |
getSystemRelationships()
Finds all the relationships in the database, including system tables. |
Table |
getSystemTable(String tableName)
Returns a reference to any available table in this access database, including system tables. |
Set<String> |
getSystemTableNames()
|
Table |
getTable(String name)
|
TableMetaData |
getTableMetaData(String name)
|
Set<String> |
getTableNames()
|
TimeZone |
getTimeZone()
Gets currently configured TimeZone (always non- null ). |
PropertyMap |
getUserDefinedProperties()
|
boolean |
isAllowAutoNumberInsert()
Gets current allow auto number insert policy. |
boolean |
isEnforceForeignKeys()
Gets current foreign-key enforcement policy. |
boolean |
isLinkedTable(Table table)
Returns true if this Database links to the given Table, false otherwise. |
Iterator<Table> |
iterator()
|
TableIterableBuilder |
newIterable()
Convenience method for constructing a new TableIterableBuilder for this cursor. |
void |
setAllowAutoNumberInsert(Boolean allowAutoNumInsert)
Sets the new auto number insert policy for the database (unless overridden at the Table level). |
void |
setCharset(Charset newCharset)
Sets a new Charset. |
void |
setColumnOrder(Table.ColumnOrder newColumnOrder)
Sets a new Table.ColumnOrder. |
void |
setColumnValidatorFactory(ColumnValidatorFactory newFactory)
Sets a new ColumnValidatorFactory. |
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. |
Field Detail |
---|
static final boolean DEFAULT_AUTO_SYNC
true
). this is slower,
but leaves more chance of a useable database in the face of failures.
static final Table.ColumnOrder DEFAULT_COLUMN_ORDER
static final String TIMEZONE_PROPERTY
static final String CHARSET_PROPERTY_PREFIX
static final String RESOURCE_PATH_PROPERTY
static final String BROKEN_NIO_PROPERTY
FileChannel.transferFrom
)
static final String COLUMN_ORDER_PROPERTY
Table.ColumnOrder
enum
values.
static final String FK_ENFORCE_PROPERTY
true
.
static final String ALLOW_AUTONUM_INSERT_PROPERTY
false
.
Method Detail |
---|
File getFile()
Set<String> getTableNames() throws IOException
IOException
Set<String> getSystemTableNames() throws IOException
getSystemTable(java.lang.String)
.
Extreme care should be taken if modifying these tables
directly!.
IOException
Iterator<Table> iterator()
iterator
in interface Iterable<Table>
RuntimeIOException
- 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.TableIterableBuilder newIterable()
Table getTable(String name) throws IOException
name
- User table name (case-insensitive)
IOException
TableMetaData getTableMetaData(String name) throws IOException
name
- Table name (case-insensitive), may be any table type
(i.e. includes system or linked tables).
IOException
List<Relationship> getRelationships(Table table1, Table table2) throws IOException
IOException
List<Relationship> getRelationships(Table table) throws IOException
IOException
List<Relationship> getRelationships() throws IOException
IOException
List<Relationship> getSystemRelationships() throws IOException
IOException
List<Query> getQueries() throws IOException
IOException
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
PropertyMap getDatabaseProperties() throws IOException
IOException
PropertyMap getSummaryProperties() throws IOException
IOException
PropertyMap getUserDefinedProperties() throws IOException
IOException
String getDatabasePassword() throws IOException
null
if none set.
IOException
void createLinkedTable(String name, String linkedDbName, String linkedTableName) throws IOException
name
- Name of the table to create in this databaselinkedDbName
- path to the linked databaselinkedTableName
- name of the table in the linked database
IOException
void flush() throws IOException
flush
in interface Flushable
IOException
void close() throws IOException
close
in interface Closeable
IOException
ErrorHandler getErrorHandler()
null
).
This will be used to handle all errors unless overridden at the Table or
Cursor level.
void setErrorHandler(ErrorHandler newErrorHandler)
null
, resets to the
ErrorHandler.DEFAULT
.
LinkResolver getLinkResolver()
null
).
This will be used to handle all linked database loading.
void setLinkResolver(LinkResolver newLinkResolver)
null
, resets to the
LinkResolver.DEFAULT
.
Map<String,Database> getLinkedDatabases()
boolean isLinkedTable(Table table) throws IOException
true
if this Database links to the given Table, false
otherwise.
IOException
TimeZone getTimeZone()
null
).
void setTimeZone(TimeZone newTimeZone)
null
, resets to the default value.
Charset getCharset()
null
).
void setCharset(Charset newCharset)
null
, resets to the default value.
Table.ColumnOrder getColumnOrder()
Table.ColumnOrder
(always non-null
).
void setColumnOrder(Table.ColumnOrder newColumnOrder)
null
, resets to the default value.
boolean isEnforceForeignKeys()
void setEnforceForeignKeys(Boolean newEnforceForeignKeys)
null
, resets to
the default value.
boolean isAllowAutoNumberInsert()
true
allows the caller to optionally set the value explicitly when
adding or updating rows (if a value is not provided, it will still be
handled internally by the Table). This value can be set database-wide
using setAllowAutoNumberInsert(java.lang.Boolean)
and/or on a per-table basis using
Table.setAllowAutoNumberInsert(java.lang.Boolean)
(and/or on a jvm-wide using the
ALLOW_AUTONUM_INSERT_PROPERTY
system property). Note that
enabling this feature should be done with care to reduce the
chances of screwing up the database.
void setAllowAutoNumberInsert(Boolean allowAutoNumInsert)
null
, resets to the default
value.
ColumnValidatorFactory getColumnValidatorFactory()
null
).
void setColumnValidatorFactory(ColumnValidatorFactory newFactory)
null
, resets to the
default value. The configured ColumnValidatorFactory will be used to
create ColumnValidator instances on any user tables loaded from
this point onward (this will not be used for system tables).
Database.FileFormat getFileFormat() throws IOException
IllegalStateException
- if the file format cannot be determined
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |