本文整理汇总了Java中org.sqlite.javax.SQLiteConnectionPoolDataSource类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteConnectionPoolDataSource类的具体用法?Java SQLiteConnectionPoolDataSource怎么用?Java SQLiteConnectionPoolDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteConnectionPoolDataSource类属于org.sqlite.javax包,在下文中一共展示了SQLiteConnectionPoolDataSource类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的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();
}
示例2: getConnection
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
private static Connection getConnection() throws SQLException {
SQLiteConfig config = new SQLiteConfig();
config.enforceForeignKeys(true);
SQLiteConnectionPoolDataSource dataSource = new SQLiteConnectionPoolDataSource();
dataSource.setUrl("jdbc:sqlite:" + DATABASE.getAbsolutePath().replace("\\", "/"));
dataSource.setConfig(config);
return dataSource.getConnection();
}
示例3: connectionTest
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
@Test
public void connectionTest () throws SQLException {
ConnectionPoolDataSource ds = new SQLiteConnectionPoolDataSource();
PooledConnection pooledConn = ds.getPooledConnection();
Connection handle = pooledConn.getConnection();
assertFalse(handle.isClosed());
assertTrue(handle.createStatement().execute("select 1"));
Connection handle2 = pooledConn.getConnection();
assertTrue(handle.isClosed());
try {
handle.createStatement().execute("select 1");
fail();
}
catch (SQLException e) {
assertEquals("Connection is closed", e.getMessage());
}
assertTrue(handle2.createStatement().execute("select 1"));
handle2.close();
handle = pooledConn.getConnection();
assertTrue(handle.createStatement().execute("select 1"));
pooledConn.close();
assertTrue(handle.isClosed());
}
示例4: getConnection
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
Connection getConnection() throws SQLException, ClassNotFoundException {
if (!databaseFolder.exists()) {
databaseFolder.mkdir();
}
Class.forName("org.sqlite.JDBC");
SQLiteConnectionPoolDataSource dataSource = new SQLiteConnectionPoolDataSource();
dataSource.setUrl("jdbc:sqlite:" + databaseFolder + "/" + this.sandboxId + ".db");
return dataSource.getConnection();
}
示例5: StatementBuilder
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
StatementBuilder(SQLiteConnectionPoolDataSource dataSource, @Nullable Transaction transaction) {
this.transaction = transaction;
try {
if (transaction == null) {
conn = dataSource.getPooledConnection().getConnection();
} else {
conn = transaction.getConnection();
}
} catch (SQLException e) {
log.error("Unexpected.", e);
}
}
示例6: Transaction
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
Transaction(SQLiteConnectionPoolDataSource dataSource) {
this.dataSource = checkNotNull(dataSource);
}
示例7: StoreReader
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
StoreReader(SQLiteConnectionPoolDataSource dataSource, @Nullable Transaction transaction) {
super(dataSource, transaction);
}
示例8: StoreWriter
import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
StoreWriter(SQLiteConnectionPoolDataSource dataSource, @Nullable Transaction transaction) {
super(dataSource, transaction);
}