当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseBuilder类代码示例

本文整理汇总了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);
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:25,代码来源:LinkMatrixMDB.java

示例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));
	}
}
 
开发者ID:mbrigl,项目名称:mdb2sqlite,代码行数:25,代码来源:MDB2SQLite.java

示例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();
}
 
开发者ID:andrew-nguyen,项目名称:ucanaccess,代码行数:17,代码来源:UcanaccessTestBase.java

示例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();
  }
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:26,代码来源:MdbLoader.java

示例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);
	}
}
 
开发者ID:ansell,项目名称:csvsum,代码行数:9,代码来源:AccessMapper.java

示例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);
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:15,代码来源:JackcessDenseObjectMatrix2D.java

示例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();
}
 
开发者ID:SmallLars,项目名称:esadb,代码行数:8,代码来源:KampfDB.java

示例8: getCalendar

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入依赖的package包/类
/**
 * @usage _advanced_method_
 */
Calendar getCalendar() {
  if(_calendar == null) {
    _calendar = DatabaseBuilder.toCompatibleCalendar(
        Calendar.getInstance(_timeZone));
  }
  return _calendar;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:11,代码来源:DatabaseImpl.java

示例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());
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:15,代码来源:UsageMapTest.java

示例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();
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:39,代码来源:CodecHandlerTest.java

示例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;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:30,代码来源:JetFormatTest.java

示例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);
}
 
开发者ID:codemumbler,项目名称:mdb-oracle,代码行数:10,代码来源:MDBReader.java

示例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;
}
 
开发者ID:hzpz,项目名称:access-export,代码行数:10,代码来源:Main.java

示例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;
}
 
开发者ID:datacleaner,项目名称:metamodel_extras,代码行数:15,代码来源:AccessDataContext.java

示例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");
	}
}
 
开发者ID:amgohan,项目名称:jackcess-orm,代码行数:11,代码来源:AccessDao.java


注:本文中的com.healthmarketscience.jackcess.DatabaseBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。