• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SQLiteConnectionPoolDataSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:27,代码来源:BaseStore.java


示例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();
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:9,代码来源:SQL.java


示例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());
}
 
开发者ID:decamp,项目名称:sqlcipher-jdbc,代码行数:30,代码来源:SQLiteConnectionPoolDataSourceTest.java


示例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();
    }
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:SqliteIndexedStorageUtility.java


示例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);
  }
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:14,代码来源:StatementBuilder.java


示例6: Transaction

import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
Transaction(SQLiteConnectionPoolDataSource dataSource) {
  this.dataSource = checkNotNull(dataSource);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:4,代码来源:Transaction.java


示例7: StoreReader

import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
StoreReader(SQLiteConnectionPoolDataSource dataSource, @Nullable Transaction transaction) {
  super(dataSource, transaction);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:4,代码来源:StoreReader.java


示例8: StoreWriter

import org.sqlite.javax.SQLiteConnectionPoolDataSource; //导入依赖的package包/类
StoreWriter(SQLiteConnectionPoolDataSource dataSource, @Nullable Transaction transaction) {
  super(dataSource, transaction);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:4,代码来源:StoreWriter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JoinPredecessor类代码示例发布时间:2022-05-22
下一篇:
Java CndImporter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap