public class DatabaseBuilder extends Object
Database
.
Simple example usage:
Database db = DatabaseBuilder.open(new File("test.mdb"));
Advanced example usage:
Database db = new DatabaseBuilder(new File("test.mdb")) .setReadOnly(true) .open();
Constructor and Description |
---|
DatabaseBuilder() |
DatabaseBuilder(File mdbFile) |
DatabaseBuilder(Path mdbFile) |
Modifier and Type | Method and Description |
---|---|
Database |
create()
Creates a new Database using the configured information.
|
static Database |
create(Database.FileFormat fileFormat,
File mdbFile)
Create a new Database for the given fileFormat
|
static SimpleDateFormat |
createDateFormat(String formatStr)
Returns a SimpleDateFormat for the given format string which is
configured with a compatible Calendar instance (see
toCompatibleCalendar(java.util.Calendar) ). |
static ColumnBuilder |
newColumn(String name)
Convenience method for constructing a ColumnBuilder.
|
static ColumnBuilder |
newColumn(String name,
DataType type)
Convenience method for constructing a TableBuilder.
|
static DatabaseBuilder |
newDatabase()
Convenience method for constructing a DatabaseBuilder.
|
static DatabaseBuilder |
newDatabase(File file)
Convenience method for constructing a DatabaseBuilder.
|
static DatabaseBuilder |
newDatabase(Path path)
Convenience method for constructing a DatabaseBuilder.
|
static IndexBuilder |
newIndex(String name)
Convenience method for constructing an IndexBuilder.
|
static IndexBuilder |
newPrimaryKey(String... colNames)
Convenience method for constructing a primary key IndexBuilder.
|
static RelationshipBuilder |
newRelationship(String fromTable,
String toTable)
Convenience method for constructing a RelationshipBuilder.
|
static RelationshipBuilder |
newRelationship(Table fromTable,
Table toTable)
Convenience method for constructing a RelationshipBuilder.
|
static TableBuilder |
newTable(String name)
Convenience method for constructing a TableBuilder.
|
static TableBuilder |
newTable(String name,
boolean escapeIdentifiers)
Convenience method for constructing a TableBuilder.
|
Database |
open()
Opens an existingnew Database using the configured information.
|
static Database |
open(File mdbFile)
Open an existing Database.
|
static Database |
open(Path mdbFile)
Open an existing Database.
|
DatabaseBuilder |
putDatabaseProperty(String name,
DataType type,
Object value)
Sets the database property with the given name and type to the given
value.
|
DatabaseBuilder |
putDatabaseProperty(String name,
Object value)
Sets the database property with the given name to the given value.
|
DatabaseBuilder |
putSummaryProperty(String name,
DataType type,
Object value)
Sets the summary database property with the given name and type to
the given value.
|
DatabaseBuilder |
putSummaryProperty(String name,
Object value)
Sets the summary database property with the given name to the given
value.
|
DatabaseBuilder |
putUserDefinedProperty(String name,
DataType type,
Object value)
Sets the user-defined database property with the given name and type to
the given value.
|
DatabaseBuilder |
putUserDefinedProperty(String name,
Object value)
Sets the user-defined database property with the given name to the given
value.
|
DatabaseBuilder |
setAutoSync(boolean autoSync)
Sets whether or not to enable auto-syncing on write.
|
DatabaseBuilder |
setChannel(FileChannel channel)
Sets a pre-opened FileChannel.
|
DatabaseBuilder |
setCharset(Charset charset)
Sets the Charset to use, if
null , uses default. |
DatabaseBuilder |
setCodecProvider(CodecProvider codecProvider)
Sets the CodecProvider for handling page encoding/decoding, may be
null if no special encoding is necessary |
DatabaseBuilder |
setFile(File mdbFile)
|
DatabaseBuilder |
setFileFormat(Database.FileFormat fileFormat)
Sets the version of new database (
create() only). |
DatabaseBuilder |
setIgnoreBrokenSystemCatalogIndex(boolean ignore)
Sets flag which, if
true , will make the database ignore the index
on the system catalog when looking up tables. |
DatabaseBuilder |
setPath(Path mdbFile)
|
DatabaseBuilder |
setReadOnly(boolean readOnly)
Sets flag which, iff
true , will force opening file in
read-only mode (open() only). |
DatabaseBuilder |
setTimeZone(TimeZone timeZone)
Sets the TimeZone to use for interpreting dates, if
null , uses
default |
static Calendar |
toCompatibleCalendar(Calendar cal)
Ensures that the given
Calendar is configured to be compatible
with how Access handles dates. |
public DatabaseBuilder()
public DatabaseBuilder(File mdbFile)
public DatabaseBuilder(Path mdbFile)
public DatabaseBuilder setFile(File mdbFile)
open()
or target file for
new database for create()
(in which case, tf this file already
exists, it will be overwritten.)public DatabaseBuilder setPath(Path mdbFile)
open()
or target file for
new database for create()
(in which case, tf this file already
exists, it will be overwritten.)public DatabaseBuilder setReadOnly(boolean readOnly)
true
, will force opening file in
read-only mode (open()
only).public DatabaseBuilder setAutoSync(boolean autoSync)
true
,
write operations will be immediately flushed to disk upon completion.
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 Database.flush()
.public DatabaseBuilder setCharset(Charset charset)
null
, uses default.public DatabaseBuilder setTimeZone(TimeZone timeZone)
null
, uses
defaultpublic DatabaseBuilder setCodecProvider(CodecProvider codecProvider)
null
if no special encoding is necessarypublic DatabaseBuilder setFileFormat(Database.FileFormat fileFormat)
create()
only).public DatabaseBuilder setChannel(FileChannel channel)
MemFileChannel
). If provided, the File parameter will be
available from Database.getFile()
, but otherwise ignored.public DatabaseBuilder putDatabaseProperty(String name, Object value)
PropertyMap.put(String,Object)
for details on determining the
property type).public DatabaseBuilder putDatabaseProperty(String name, DataType type, Object value)
public DatabaseBuilder putSummaryProperty(String name, Object value)
PropertyMap.put(String,Object)
for details on determining the
property type).public DatabaseBuilder putSummaryProperty(String name, DataType type, Object value)
public DatabaseBuilder putUserDefinedProperty(String name, Object value)
PropertyMap.put(String,Object)
for details on determining the
property type).public DatabaseBuilder putUserDefinedProperty(String name, DataType type, Object value)
public DatabaseBuilder setIgnoreBrokenSystemCatalogIndex(boolean ignore)
true
, will make the database ignore the index
on the system catalog when looking up tables. This will make table
retrieval slower, but can be used to workaround broken indexes.public Database open() throws IOException
IOException
public Database create() throws IOException
IOException
public static Database open(File mdbFile) throws IOException
mdbFile
- File containing the databaseIOException
for more flexible Database opening
public static Database open(Path mdbFile) throws IOException
mdbFile
- File containing the databaseIOException
for more flexible Database opening
public static Database create(Database.FileFormat fileFormat, File mdbFile) throws IOException
fileFormat
- version of new database.mdbFile
- Location to write the new database to. If this file
already exists, it will be overwritten.IOException
for more flexible Database creation
public static SimpleDateFormat createDateFormat(String formatStr)
toCompatibleCalendar(java.util.Calendar)
).public static Calendar toCompatibleCalendar(Calendar cal)
Calendar
is configured to be compatible
with how Access handles dates. Specifically, alters the gregorian change
(the java default gregorian change switches to julian dates for dates pre
1582-10-15, whereas Access uses proleptic gregorian dates).public static DatabaseBuilder newDatabase()
public static DatabaseBuilder newDatabase(Path path)
public static DatabaseBuilder newDatabase(File file)
public static TableBuilder newTable(String name)
public static TableBuilder newTable(String name, boolean escapeIdentifiers)
public static ColumnBuilder newColumn(String name)
public static ColumnBuilder newColumn(String name, DataType type)
public static IndexBuilder newIndex(String name)
public static IndexBuilder newPrimaryKey(String... colNames)
public static RelationshipBuilder newRelationship(String fromTable, String toTable)
public static RelationshipBuilder newRelationship(Table fromTable, Table toTable)
Copyright © 2005–2024 OpenHMS. All rights reserved.