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) |
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) ). |
Database |
open()
Opens an existingnew Database using the configured information.
|
static Database |
open(File 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 |
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 setFile(File mdbFile)
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 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 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).Copyright © 2005–2018. All rights reserved.