Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite:How to use in memory

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

like image 811
junaidp Avatar asked Jan 12 '12 07:01

junaidp


1 Answers

Try:

con = DriverManager.getConnection("jdbc:sqlite::memory:");
like image 134
Paul Rigor Avatar answered Oct 22 '22 05:10

Paul Rigor