加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite:如何在内存中使用

发布时间:2020-12-12 18:51:30 所属栏目:百科 来源:网络整理
导读:我试图将我的数据存储在内存中 这就是我现在所拥有的 //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"); State
我试图将我的数据存储在内存中

这就是我现在所拥有的

//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:”]放在内存中存储我的数据,数据应该保存直到我删除它.

谢谢

解决方法

尝试:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读