sqlite:How to use in memory

僤鯓⒐⒋嵵緔 提交于 2019-11-30 17:47:56

问题


I am trying to store my data in memory

here is what i have right now

        //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));");

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 .

Thanks


回答1:


Try:

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


来源:https://stackoverflow.com/questions/8831514/sqlitehow-to-use-in-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!