我正在尝试将数据存储在内存中
这就是我现在所拥有的
//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:”]放在内存中存储我的数据,数据应该保存直到我删除它为止。
谢谢
答案 0 :(得分:7)
尝试:
con = DriverManager.getConnection("jdbc:sqlite::memory:");