sqlite:如何在内存中使用 [英] sqlite:How to use in memory

查看:32
本文介绍了sqlite:如何在内存中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的数据存储在内存中

I am trying to store my data in memory

这是我现在拥有的

//sq lite driver
Class.forName("org.sqlite.JDBC");
//database path, if it's new data base it will be created in project folder
con = DriverManager.getConnection("jdbc:sqlite:mydb.db");

Statement stat = con.createStatement(); 

stat.executeUpdate("drop table if exists weights");

//creating table
stat.executeUpdate("create table weights(id integer,"
    + "firstName varchar(30)," + "age INT," + "sex varchar(15),"
    + "weight INT," + "height INT,"
    + "idealweight INT, primary key (id));");

现在我应该把这个语句放在哪里[":memory:"]把我的这个数据存储在内存中,数据应该一直保存,直到我删除它.

Now where should i put this statement[ ":memory:"] to store my this data in memory and the data should keep saved until i delete it .

谢谢

推荐答案

尝试:

con = DriverManager.getConnection("jdbc:sqlite::memory:");

这篇关于sqlite:如何在内存中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆