java sqlite 连接池_java-在c3p0连接池中设置SQLite连接属性

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 19:15   1851   0

尝试

//put the imports where they really go, obviously...

import javax.sql.*;

import org.sqlite.*;

import com.mchange.v2.c3p0.*;

// configure SQLite

SQLiteConfig config = new org.sqlite.SQLiteConfig();

config.setReadOnly(true);

config.setPageSize(4096); //in bytes

config.setCacheSize(2000); //number of pages

config.setSynchronous(SQLiteConfig.SynchronousMode.OFF);

config.setJournalMode(SQLiteConfig.JournalMode.OFF);

// get an unpooled SQLite DataSource with the desired configuration

SQLiteDataSource unpooled = new SQLiteDataSource( config );

// get a pooled c3p0 DataSource that wraps the unpooled SQLite DataSource

DataSource pooled = DataSources.pooledDataSource( unpooled );

现在,池中的数据源将是c3p0 PooledDataSource,它包装了已根据需要配置的SQLite未池化数据源.

另请参阅我从here下载的用于SQLite JDBC的javadocs来回答此问题.

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP