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


Java SQLiteConfig.setJournalMode方法代码示例

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


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

示例1: create

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public static Connection create(String url) throws Exception {
	Class.forName("org.sqlite.JDBC");
	SQLiteConfig config = new SQLiteConfig();
	config.setJournalMode(SQLiteConfig.JournalMode.WAL);
	config.setBusyTimeout("5000");
	config.setTransactionMode(SQLiteConfig.TransactionMode.EXCLUSIVE);

	Connection conection = DriverManager.getConnection("jdbc:sqlite:", config.toProperties());

	Statement statement = conection.createStatement();
	statement.executeUpdate("BEGIN IMMEDIATE;");
	StatementUtils.runSqlScript(statement, "/com/exscudo/peer/store/sqlite/DBv1.sql");
	StatementUtils.runSqlScript(statement, "/com/exscudo/peer/store/sqlite/DBv2.sql");
	StatementUtils.runSqlScript(statement, "/com/exscudo/peer/store/sqlite/DBv2_clean.sql");
	StatementUtils.runSqlScript(statement, "/com/exscudo/peer/store/sqlite/DBv3.sql");
	StatementUtils.runSqlScript(statement, url);
	statement.executeUpdate("COMMIT;");

	return conection;
}
 
开发者ID:EonTechnology,项目名称:server,代码行数:21,代码来源:ConnectionUtils.java

示例2: CreateConnection

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
private static Connection CreateConnection(String dbname, int cache_size, boolean safe_write, boolean journal, boolean autocommit) {
    Connection connection = null;

    try {
        SQLiteConfig config = new SQLiteConfig();
        config.setCacheSize(cache_size);
        config.setSynchronous(safe_write ? SQLiteConfig.SynchronousMode.FULL : SQLiteConfig.SynchronousMode.NORMAL);
        config.setTempStore(SQLiteConfig.TempStore.MEMORY);
        config.setJournalMode(journal ? SQLiteConfig.JournalMode.TRUNCATE : SQLiteConfig.JournalMode.OFF);
        connection = DriverManager.getConnection("jdbc:sqlite:" + dbname.replaceAll("\\\\", "/"), config.toProperties());
        connection.setAutoCommit(autocommit);
    } catch (SQLException ex) {
        com.gmt2001.Console.err.printStackTrace(ex);
    }

    return connection;
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:18,代码来源:SqliteStore.java

示例3: open

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public void open() throws StoreException {
  try {
    SQLiteConfig config = new SQLiteConfig();

    // Disable fsync calls, trusting that the filesystem will do the right thing. It's not always
    // the best assumption, but we are file with losing ~1 day of data (basically, the time
    // between backups). Additionally, switch to write-ahead-logging for the journal. We could
    // turn it off completely as well, and rely on backups in the event of data loss, but that's
    // slightly more painful for development (where "crashes" are more likely).
    config.setSynchronous(SQLiteConfig.SynchronousMode.OFF);
    config.setJournalMode(SQLiteConfig.JournalMode.WAL);

    // Increase the cache size, we have plenty of memory on the server.
    config.setCacheSize(2048);

    // Enforce foreign key constraints (for some reason, the default is off)
    config.enforceForeignKeys(true);

    dataSource = new SQLiteConnectionPoolDataSource(config);
    dataSource.getPooledConnection();
    dataSource.setUrl("jdbc:sqlite:data/store/" + fileName);
  } catch(SQLException e) {
    throw new StoreException(e);
  }
  ensureVersion();
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:27,代码来源:BaseStore.java

示例4: create

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public static Storage create(String url, IInitializer loader)
		throws ClassNotFoundException, IOException, SQLException {
	Objects.requireNonNull(url);
	Objects.requireNonNull(loader);

	Class.forName("org.sqlite.JDBC");
	SQLiteConfig config = new SQLiteConfig();
	config.setJournalMode(SQLiteConfig.JournalMode.WAL);
	config.setBusyTimeout("5000");
	config.setTransactionMode(SQLiteConfig.TransactionMode.EXCLUSIVE);

	Connection connection = DriverManager.getConnection(url, config.toProperties());
	loader.initialize(connection);
	return new Storage(connection);
}
 
开发者ID:EonTechnology,项目名称:server,代码行数:16,代码来源:Storage.java


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