本文整理汇总了Java中org.sqlite.SQLiteConfig.setSynchronous方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteConfig.setSynchronous方法的具体用法?Java SQLiteConfig.setSynchronous怎么用?Java SQLiteConfig.setSynchronous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sqlite.SQLiteConfig
的用法示例。
在下文中一共展示了SQLiteConfig.setSynchronous方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: CreateConnection
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
private static Connection CreateConnection(String dbname, int cache_size, boolean safe_write)
{
Connection connection = null;
try
{
SQLiteConfig config = new SQLiteConfig();
config.setCacheSize(cache_size);
config.setSynchronous(safe_write ? SQLiteConfig.SynchronousMode.FULL : SQLiteConfig.SynchronousMode.NORMAL);
connection = DriverManager.getConnection("jdbc:sqlite:" + dbname.replaceAll("\\\\", "/"), config.toProperties());
connection.setAutoCommit(true);
} catch (SQLException ex)
{
com.gmt2001.Console.err.printStackTrace(ex);
}
return connection;
}
示例3: start
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
@Override
public void start() throws SQLException, ClassNotFoundException {
File file = new File(metaData.getDataPath()+File.separator+metaData.getDatabaseName());
if(!file.exists()){
throw new SQLException("File not found");
}
SQLiteConfig conf = new SQLiteConfig();
conf.setSynchronous(SynchronousMode.OFF);
String url = Utils.replaceParams(dbConfig.getDbURL(), metaData);
url = url.replace("__FILE_SEPARATOR__", File.separator);
String driver = dbConfig.getDriver();
Class.forName(driver);
Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), metaData);
SQLiteConfig config = new SQLiteConfig(prop);
config.setSynchronous(SynchronousMode.OFF);
conn = DriverManager.getConnection(url, config.toProperties());
// conn.setAutoCommit(false);
}
示例4: connect
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
* Create a connection to the SQLite db
*
* @param url an url formating string to the sqlte db
* @param info aditional properties for the connection
* @return Connection the jdbc connection
*/
public Connection connect(final String url, final Properties info) throws SQLException
{
String sqliteUrl = adaptUrl(url);
SQLiteConfig config = new SQLiteConfig(info);
config.setSharedCache(true);
config.setSynchronous(SynchronousMode.NORMAL);
if(( config.getOpenModeFlags() & SQLiteOpenMode.READWRITE.flag) > 0) {
config.setTransactionMode(TransactionMode.IMMEDIATE);
} else if(( config.getOpenModeFlags() & SQLiteOpenMode.READONLY.flag) > 0) {
config.setTransactionMode(TransactionMode.DEFFERED);
}
Connection connection = sqliteJDBC.connect(sqliteUrl, config.toProperties());
return new SQLiteConnectionWrapper(connection);
}
示例5: 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();
}
示例6: ScoreDatabaseAccessor
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public ScoreDatabaseAccessor(String path) throws ClassNotFoundException {
Class.forName("org.sqlite.JDBC");
SQLiteConfig conf = new SQLiteConfig();
conf.setSharedCache(true);
conf.setSynchronous(SynchronousMode.OFF);
// conf.setJournalMode(JournalMode.MEMORY);
SQLiteDataSource ds = new SQLiteDataSource(conf);
ds.setUrl("jdbc:sqlite:" + path);
qr = new QueryRunner(ds);
}
示例7: SongInformationAccessor
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public SongInformationAccessor(String filepath) throws ClassNotFoundException {
Class.forName("org.sqlite.JDBC");
SQLiteConfig conf = new SQLiteConfig();
conf.setSharedCache(true);
conf.setSynchronous(SynchronousMode.OFF);
// conf.setJournalMode(JournalMode.MEMORY);
ds = new SQLiteDataSource(conf);
ds.setUrl("jdbc:sqlite:" + filepath);
qr = new QueryRunner(ds);
createTable();
}
示例8: SQLiteSongDatabaseAccessor
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public SQLiteSongDatabaseAccessor(String filepath, String[] bmsroot) throws ClassNotFoundException {
Class.forName("org.sqlite.JDBC");
SQLiteConfig conf = new SQLiteConfig();
conf.setSharedCache(true);
conf.setSynchronous(SynchronousMode.OFF);
// conf.setJournalMode(JournalMode.MEMORY);
ds = new SQLiteDataSource(conf);
ds.setUrl("jdbc:sqlite:" + filepath);
qr = new QueryRunner(ds);
root = Paths.get(".");
this.bmsroot = bmsroot;
createTable();
}
示例9: ScoreLogDatabaseAccessor
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public ScoreLogDatabaseAccessor(String path) throws ClassNotFoundException {
Class.forName("org.sqlite.JDBC");
SQLiteConfig conf = new SQLiteConfig();
conf.setSharedCache(true);
conf.setSynchronous(SynchronousMode.OFF);
// conf.setJournalMode(JournalMode.MEMORY);
ds = new SQLiteDataSource(conf);
ds.setUrl("jdbc:sqlite:" + path);
qr = new QueryRunner(ds);
createTable();
}
示例10: start
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
@Override
public void start() throws SQLException, ClassNotFoundException {
SQLiteConfig conf = new SQLiteConfig();
conf.setSynchronous(SynchronousMode.OFF);
String url = Utils.replaceParams(dbConfig.getDbURL(), metaData);
url = url.replace("__FILE_SEPARATOR__", File.separator);
String driver = dbConfig.getDriver();
Class.forName(driver);
Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), metaData);
SQLiteConfig config = new SQLiteConfig(prop);
config.setSynchronous(SynchronousMode.OFF);
conn = DriverManager.getConnection(url, config.toProperties());
// conn.setAutoCommit(false);
}