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


Java SqlJetDb.open方法代码示例

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


在下文中一共展示了SqlJetDb.open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: export

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的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

示例2: P2PBlobRepositoryFS

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
public P2PBlobRepositoryFS(File repositoryDirectory) throws Exception {
	this.repositoryDirectory=repositoryDirectory;
	if(repositoryDirectory.exists()==false){
	  repositoryDirectory.mkdirs();
	}
	
	try {
		File dbFile=new File(repositoryDirectory, REPOSITORY_DB_FILENAME);
		boolean schemaNeedsToBeCreated=dbFile.exists()==false;
		db = new SqlJetDb(dbFile, true);
		db.open();
		maybeCreateSchema(schemaNeedsToBeCreated);
	} catch (SqlJetException e) {
		throw new RuntimeException(e);
	}
	
	for(File nonRepositoryFile:repositoryDirectory.listFiles(nonRepositoryFilenameFilter)){
		importFileIntoRepository(nonRepositoryFile);
	}

}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:22,代码来源:P2PBlobRepositoryFS.java

示例3: HashToPublicKeyDB

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
public HashToPublicKeyDB() {
	super(UnsignedLong.ONE); // FIXME Get the db version number from SQL
	try {
		db = new SqlJetDb(SqlJetDb.IN_MEMORY, true);
		db.open();
		maybeCreateSchema();
	} catch (SqlJetException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:11,代码来源:HashToPublicKeyDB.java

示例4: SelfRegistrationDHT

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
public SelfRegistrationDHT(ServerMain serverMain) throws Exception {
  super(serverMain);
  setEntryTimeToLive(1, TimeUnit.DAYS);
  setEntryMaximumCardinality(1000);
  setEntryOverflowHandling(OverflowHandling.LIFO); //LIFO or FIFO    

  File serverFile=serverMain.getConfig().getFileRelativeFromConfigDirectory(DHT_FILENAME);
  boolean dbExists=serverFile.exists();
  db = new SqlJetDb(serverFile, true);
  db.open();
  if(dbExists==false){
    createSchema();
  }
  dhtValueTable=db.getTable(DHT_VALUE_TABLE_NAME);
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:16,代码来源:SelfRegistrationDHT.java

示例5: getDatabaseConnection

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
/**
 * Get a connection to the database for the current thread. Also closes all invalid connections for the current
 * thread.
 * @return
 *      The connection or null if the connection couldn't be established.
 *
 * @see #connections
 */
private SqlJetDb getDatabaseConnection() {
    Thread t = Thread.currentThread();
    File folder = folderHolder.getKachleCacheFolder().getEffectiveFile();
    File f = new File(folder, FILE_NAME);
    AbstractMap.SimpleImmutableEntry<Thread, File> mapKey = new AbstractMap.SimpleImmutableEntry<>(t, f);

    if (connections.containsKey(mapKey)) {
        // Got a valid connection
        return connections.get(mapKey);
    } else {
        try {
            // create a new connection
            SqlJetDb database = SqlJetDb.open(f, true);

            // Initialize the DB if needed
            if (!isDbInitialized(database)) {
                initDb(database);
            }

            // Close all deprecated connections (should be exactly one or zero)
            // Done here for synchronization reasons. This way, we never close an active connection that's
            // needed elsewhere at the same moment and there's always at most one connection per thread.
            for (Map.Entry<Map.Entry<Thread, File>, SqlJetDb> conn : connections.entrySet()) {
                if (conn.getKey().getKey().equals(t)) {
                    conn.getValue().close();
                    connections.remove(conn.getKey());
                }
            }

            // Now, store the new connection and return it
            connections.put(mapKey, database);
            return database;
        } catch (SqlJetException e) {
            log.error("Unable to establish the DB connection!", e);
            return null;
        }
    }
}
 
开发者ID:Danstahr,项目名称:Geokuk,代码行数:47,代码来源:KachleDBManager.java


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