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


Java DatabaseBuilder.open方法代码示例

本文整理汇总了Java中com.healthmarketscience.jackcess.DatabaseBuilder.open方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseBuilder.open方法的具体用法?Java DatabaseBuilder.open怎么用?Java DatabaseBuilder.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.healthmarketscience.jackcess.DatabaseBuilder的用法示例。


在下文中一共展示了DatabaseBuilder.open方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: open

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入方法依赖的package包/类
public Database open(File fl,String pwd) throws IOException {
	DatabaseBuilder dbd =new DatabaseBuilder(fl);
	dbd.setAutoSync(false);
	try {
		dbd.setReadOnly(false);
		
		return  dbd.open();
	} catch (IOException e) {
		dbd.setReadOnly(true);
		return dbd.open();

	}
}
 
开发者ID:andrew-nguyen,项目名称:ucanaccess,代码行数:14,代码来源:DefaultJackcessOpener.java

示例11: hasPassword

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入方法依赖的package包/类
private static boolean hasPassword(File fl) throws IOException {
	Database db;
	try{
	db = DatabaseBuilder.open(fl);
      }catch(IOException e){
    	  DatabaseBuilder dbb=new  DatabaseBuilder();
    	  dbb.setReadOnly(true);
	      db= dbb.open();
	
    }
	String pwd = db.getDatabasePassword();
	db.close();
	return pwd != null;
}
 
开发者ID:andrew-nguyen,项目名称:ucanaccess,代码行数:15,代码来源:Main.java

示例12: dumpToCSVs

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入方法依赖的package包/类
private static void dumpToCSVs(InputStream input, Path outputDir, String csvPrefix, boolean debug,
		boolean addTableNamePrefix) throws IOException {
	Path tempFile = Files.createTempFile("Source-accessdb", ".accdb");
	Files.copy(input, tempFile, StandardCopyOption.REPLACE_EXISTING);

	try {
		final CsvSchema schema = CSVStream
				.buildSchema(Arrays.asList("OldField", "NewField", "Language", "Mapping"));
		try (final Database db = DatabaseBuilder.open(tempFile.toFile());
				final Writer columnCsv = Files
						.newBufferedWriter(outputDir.resolve(csvPrefix + "AutoMapping-Columns.csv"));
				final SequenceWriter columnCsvWriter = CSVStream.newCSVWriter(new BufferedWriter(columnCsv),
						schema);) {
			for (String tableName : db.getTableNames()) {
				Table table = db.getTable(tableName);

				if (debug) {
					debugTable(table, columnCsvWriter);
				}

				System.out.println("");
				String csvName = csvPrefix + tableName + ".csv";
				Path csvPath = outputDir.resolve(csvName);
				System.out.println("Converting " + tableName + " to CSV: " + csvPath.toAbsolutePath().toString());

				String[] tempArray = new String[table.getColumnCount()];
				int x = 0;
				for (Column nextColumn : table.getColumns()) {
					if (addTableNamePrefix) {
						tempArray[x++] = tableName + "." + nextColumn.getName();
					} else {
						tempArray[x++] = nextColumn.getName();
					}
				}

				final CsvSchema fullFileSchema = CSVStream.buildSchema(Arrays.asList(tempArray));
				try (final Writer fullFileCsv = Files.newBufferedWriter(csvPath);
						final SequenceWriter fullFileCsvWriter = CSVStream
								.newCSVWriter(new BufferedWriter(fullFileCsv), fullFileSchema);) {
					int rows = 0;
					for (Row nextRow : table) {
						int i = 0;
						for (Object nextValue : nextRow.values()) {
							if (nextValue == null) {
								tempArray[i++] = null;
							} else if (nextValue instanceof Date) {
								tempArray[i++] = CSVUtil.oldDateToISO8601LocalDateTime((Date) nextValue);
							} else {
								tempArray[i++] = nextValue.toString();
							}
						}
						fullFileCsvWriter.write(Arrays.asList(tempArray));
						rows++;
					}
					System.out.println("Converted " + rows + " rows from table " + tableName);
				}
				System.out.println("");
				System.out.println("----------------------------");
			}
		}
	} finally {
		Files.deleteIfExists(tempFile);
	}
}
 
开发者ID:ansell,项目名称:csvsum,代码行数:65,代码来源:AccessMapper.java

示例13: parseSchema

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入方法依赖的package包/类
/**
 * Interpret the schema and create postgres structures
 * 
 * @param databaseFile
 * @param commit
 * @param serverName
 * @param databaseName
 * @return a map of TableImportResult instances with table creation results
 * @throws IOException
 */
private Map<String, TableImportResult> parseSchema(File databaseFile,
		boolean commit, String serverName, String databaseName)
		throws IOException {
	Database database = DatabaseBuilder.open(databaseFile);

	Map<String, TableImportResult> results = new HashMap<String, TableImportResult>();

	//
	// Tables
	//
	Set<String> tablesName = database.getTableNames();
	Iterator<String> tables = tablesName.iterator();
	while (tables.hasNext()) {
		Table table = database.getTable(tables.next());
		TableImportResult result = new TableImportResult();
		if (!excludeTable(table.getName())) {
			if (!createTableStructure(table, commit, serverName,
					databaseName)) {
				log.error("Unable to create table structure");
				result.setTableCreateResult(TableImportResult.FAILED);
			} else {
				result.setTableCreateResult(TableImportResult.SUCCESSFUL);
			}
		}
		results.put(getNormalisedTableName(table.getName()), result);
	}

	//
	// Constraints
	//
	Map<String, TableImportResult> constraintResults = createForeignKeys(
			serverName, databaseName, database, commit);

	//
	// Merge results
	//
	for (String key : results.keySet()) {
		results.get(key).merge(constraintResults.get(key));
	}

	return results;
}
 
开发者ID:ox-it,项目名称:ords-database-api,代码行数:53,代码来源:PostgresAccessDatabaseServiceImpl.java

示例14: resolveLinkedDatabase

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入方法依赖的package包/类
public Database resolveLinkedDatabase(Database linkerDb,
                                      String linkeeFileName)
  throws IOException
{
  return DatabaseBuilder.open(new File(linkeeFileName));
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:7,代码来源:LinkResolver.java

示例15: iteratorRaw

import com.healthmarketscience.jackcess.DatabaseBuilder; //导入方法依赖的package包/类
private TupleIterator iteratorRaw() throws IOException {
	return new TupleIterator() {
		Database db = DatabaseBuilder.open(new File(meta.getFileSpec()));
		Table table = db.getTable(meta.getTable());
		Cursor cursor = CursorBuilder.createCursor(table);
		Row currentLine = null;
		
		@Override
		public boolean hasNext() {
			if (currentLine != null)
				return true;
			try {
				if (cursor.moveToNextRow()) {
					currentLine = cursor.getCurrentRow();
					if (currentLine == null)
						return false;
					return true;
				}
			} catch (IOException ioe) {
				System.out.println("TableACCDB[1]: error " + ioe);					
			}
			return false;
		}

		@Override
		public ValueTuple next() {
			if (hasNext())
				try {
					return toTuple(table, currentLine);
				} finally {
					currentLine = null;
				}
			else
				return null;
		}

		@Override
		public void close() {
			try {
				db.close();
			} catch (IOException e) {
				System.out.println("TableACCDB[2]: error " + e);
			}
		}
	};		
}
 
开发者ID:DaveVoorhis,项目名称:Rel,代码行数:47,代码来源:TableACCDB.java


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