楼主:
JGC18 (JGC)
2015-06-29 12:07:16请教各位
请问有人使用过jdbc去连接sqlite吗
因为我发现每次程式一起来, 我去getConnection()这一步
都会很慢, 执行时间最长有到7sec, 不知道有没有前辈欲过类似问题呢?
public Connection getConnection() throws SQLException
{
Connection con = null;
SQLiteConfig config = new SQLiteConfig();
// config.setReadOnly(true);
config.setSharedCache(true);
config.enableRecursiveTriggers(true);
SQLiteDataSource ds = new SQLiteDataSource(config);
ds.setUrl("jdbc:sqlite:config/sample.db");
logger.debug("before getConnection");
con = ds.getConnection();// <
作者: MonyemLi (life) 2015-06-30 07:36:00
直接用jdbc呼叫吧,不会慢到有感觉不确定你用的ds里面怎么实作的,不过一般不会一直new
作者: kojilin (阿~~小达达) 2015-06-30 14:22:00
但要跑才执行的话就不管怎样都会慢,不然就是启动时背后先赶快getConntection,画面或是什么的先呈现,来避免慢另外他有source..不然也可以看看到底慢在get里面哪里