本文整理汇总了Java中com.healthmarketscience.jackcess.DatabaseBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseBuilder类的具体用法?Java DatabaseBuilder怎么用?Java DatabaseBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseBuilder类属于com.healthmarketscience.jackcess包,在下文中一共展示了DatabaseBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFile
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
public static final JackcessDenseObjectMatrix2D toFile(File file, Object... parameters)
throws IOException {
Database db = DatabaseBuilder.open(file);
Set<String> tables = db.getTableNames();
String tablename = null;
if (parameters.length != 0) {
tablename = StringUtil.convert(parameters[0]);
}
if (tablename == null) {
if (tables.size() == 1) {
tablename = db.getTableNames().iterator().next();
}
}
db.close();
if (tablename == null) {
throw new IllegalArgumentException(
"please append the table name, i.e. one of these tables: " + tables);
}
return new JackcessDenseObjectMatrix2D(file, tablename);
}
示例2: export
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
/**
* Export the Access database to the given SQLite database. The referenced
* SQLite database should be empty.
*
* @param mdbFile The MS Access file.
* @param sqliteFile The SQLite file.
* @throws SQLException
* @throws SqlJetException
*/
public static void export(File mdbFile, File sqliteFile) throws Exception {
Database mdb = DatabaseBuilder.open(mdbFile);
SqlJetDb sqlite = SqlJetDb.open(sqliteFile, true);
sqlite.getOptions().setAutovacuum(true);
sqlite.beginTransaction(SqlJetTransactionMode.WRITE);
// Create the tables
MDB2SQLite.createTables(mdb, sqlite);
// Populate the tables
for (String tableName : mdb.getTableNames()) {
MDB2SQLite.populateTable(sqlite, mdb.getTable(tableName));
}
}
示例3: getAccessTempPath
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
public String getAccessTempPath() throws IOException {
if (fileMdb == null||!this.getClass().equals(testingClass)) {
testingClass=this.getClass();
if (this.getAccessPath() == null) {
fileMdb = File.createTempFile("test", ".mdb");
Database db = DatabaseBuilder.create(this.fileFormat, fileMdb);
db.flush();
db.close();
System.out.println("Access file version " + this.fileFormat
+ " created: " + fileMdb.getAbsolutePath());
} else {
fileMdb = copyResourceInTemp(this.getAccessPath());;
}
}
return fileMdb.getAbsolutePath();
}
示例4: loadData
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
@Override
public void loadData(List<Tuple<String, File>> files, Importer importer) throws InvalidFileException, IOException {
Database database = DatabaseBuilder.open(files.get(0).getRight());
for (String tableName : database.getTableNames()) {
importer.startCollection(tableName);
Table table = database.getTable(tableName);
List<? extends Column> columns = table.getColumns();
for (int i = 0; i < columns.size(); i++) {
importer.registerPropertyName(i, columns.get(i).getName());
}
for (Row row : table) {
importer.startEntity();
for (int colNum = 0 ; colNum < columns.size(); colNum++) {
Object cellValue = row.get(columns.get(colNum).getName());
if (cellValue == null) {
cellValue = "";
}
importer.setValue(colNum, "" + cellValue);
}
importer.finishEntity();
}
importer.finishCollection();
}
}
示例5: mapAndGetOriginTable
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
private static String mapAndGetOriginTable(Path tempDBPath, List<ValueMapping> map,
final JDefaultDict<String, ConcurrentMap<ValueMapping, Tuple2<String, String>>> foreignKeyMapping,
final ConcurrentMap<ValueMapping, Joiner> joiners) throws IOException {
try (final Database db = DatabaseBuilder.open(tempDBPath.toFile());) {
// Populate the table mapping for each value mapping
return parseTableMappings(map, db, foreignKeyMapping, joiners);
}
}
示例6: JackcessDenseObjectMatrix2D
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
public JackcessDenseObjectMatrix2D(File file, String tablename) throws IOException {
super(0, 0);
database = DatabaseBuilder.open(file);
VerifyUtil.verifyNotNull(database, "database could not be opened");
table = database.getTable(tablename);
VerifyUtil.verifyNotNull(table, "table not found in database");
columns = table.getColumns();
cursor = CursorBuilder.createCursor(table);
for (int i = 0; i < columns.size(); i++) {
setColumnLabel(i, columns.get(i).getName());
}
setLabel(tablename);
}
示例7: getDB
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
private static Database getDB(String filename) throws IOException {
DatabaseBuilder dbb = new DatabaseBuilder();
dbb.setReadOnly(true);
dbb.setFile(new File(Controller.getPath(filename)));
dbb.setCharset(Charset.forName("ISO-8859-1"));
return dbb.open();
}
示例8: getCalendar
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
/**
* @usage _advanced_method_
*/
Calendar getCalendar() {
if(_calendar == null) {
_calendar = DatabaseBuilder.toCompatibleCalendar(
Calendar.getInstance(_timeZone));
}
return _calendar;
}
示例9: checkUsageMapRead
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
private static void checkUsageMapRead(
final File dbFile, final int expectedFirstPage, final int expectedLastPage)
throws IOException {
final Database db = DatabaseBuilder.open(dbFile);
final UsageMap usageMap = UsageMap.read((DatabaseImpl)db,
PageChannel.PAGE_GLOBAL_USAGE_MAP,
PageChannel.ROW_GLOBAL_USAGE_MAP,
true);
assertEquals("Unexpected FirstPageNumber.", expectedFirstPage,
usageMap.getFirstPageNumber());
assertEquals("Unexpected LastPageNumber.", expectedLastPage,
usageMap.getLastPageNumber());
}
示例10: doTestCodecHandler
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
private static void doTestCodecHandler(boolean simple) throws Exception
{
for(Database.FileFormat ff : SUPPORTED_FILEFORMATS) {
Database db = TestUtil.create(ff);
int pageSize = ((DatabaseImpl)db).getFormat().PAGE_SIZE;
File dbFile = db.getFile();
db.close();
// apply encoding to file
encodeFile(dbFile, pageSize, simple);
db = new DatabaseBuilder(dbFile)
.setCodecProvider(simple ? SIMPLE_PROVIDER : FULL_PROVIDER)
.open();
Table t1 = new TableBuilder("test1")
.addColumn(new ColumnBuilder("id", DataType.LONG).setAutoNumber(true))
.addColumn(new ColumnBuilder("data", DataType.TEXT).setLength(250))
.setPrimaryKey("id")
.addIndex(new IndexBuilder("data_idx").addColumns("data"))
.toTable(db);
Table t2 = new TableBuilder("test2")
.addColumn(new ColumnBuilder("id", DataType.LONG).setAutoNumber(true))
.addColumn(new ColumnBuilder("data", DataType.TEXT).setLength(250))
.setPrimaryKey("id")
.addIndex(new IndexBuilder("data_idx").addColumns("data"))
.toTable(db);
int autonum = 1;
for(int i = 1; i < 2; ++i) {
writeData(t1, t2, autonum, autonum + 100);
autonum += 100;
}
db.close();
}
}
示例11: getSupportedForBasename
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
public static List<TestDB> getSupportedForBasename(Basename basename,
boolean readOnly) {
List<TestDB> supportedTestDBs = new ArrayList<TestDB>();
for (FileFormat fileFormat :
(readOnly ? SUPPORTED_FILEFORMATS_FOR_READ :
SUPPORTED_FILEFORMATS)) {
File testFile = getFileForBasename(basename, fileFormat);
if(!testFile.exists()) {
continue;
}
// verify that the db is the file format expected
try {
Database db = new DatabaseBuilder(testFile).setReadOnly(true).open();
FileFormat dbFileFormat = db.getFileFormat();
db.close();
if(dbFileFormat != fileFormat) {
throw new IllegalStateException("Expected " + fileFormat +
" was " + dbFileFormat);
}
} catch(Exception e) {
throw new RuntimeException(e);
}
supportedTestDBs.add(new TestDB(testFile, fileFormat));
}
return supportedTestDBs;
}
示例12: MDBReader
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
public MDBReader(File mdbFile) throws IOException {
if (mdbFile == null)
throw new IllegalArgumentException();
this.jackcessDatabase = DatabaseBuilder.open(mdbFile);
database = new Database();
String schemaName = mdbFile.getName();
schemaName = schemaName.replace(".mdb", "").replace(".accdb", "");
database.setSchemaName(schemaName);
}
示例13: openSourceDatabase
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
private Database openSourceDatabase(File databaseFile) throws SystemExitException {
Database database;
try {
database = new DatabaseBuilder(databaseFile).setReadOnly(true).open();
} catch (IOException e) {
throw new SystemExitException("Error opening the source database", e, EXIT_STATUS_ERROR_OPENING_SOURCE);
}
return database;
}
示例14: getDatabase
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
private Database getDatabase() {
if (_database == null) {
synchronized (this) {
if (_database == null) {
try {
_database = new DatabaseBuilder(_file).setReadOnly(true).open();
} catch (IOException e) {
throw new MetaModelException(e);
}
}
}
}
return _database;
}
示例15: AccessDao
import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
public AccessDao(File accessFile, Class<E> clazz) throws IOException {
this.accessFile = accessFile;
this.clazz = clazz;
this.mapper = new AccessMapper<E>(clazz);
db = DatabaseBuilder.open(this.accessFile);
table = db.getTable(mapper.getTableName());
if(table == null) {
throw new JackcessException("relation " + mapper.getTableName() + " does not exist");
}
}