· 6 years ago · Jun 19, 2019, 06:02 AM
1connect to an in-memory database, you use the following connection string:
2jdbc:sqLite::memory
3
4public class Main {
5
6 public static void main(String[] args) {
7 try{
8 Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\Users\Owner\Desktop\School Project\Software-Engineering---Java-Project\Nati Elmaliach java\data.db");
9 Statement statement = conn.createStatement();
10
11 //CREATE TABLES
12 statement.execute("CREATE TABLE IF NOT EXISTS CUSTOMERS (name TEXT,phone INTEGER,email TEXT)");
13
14 //INSERT TO TABLES
15 statement.execute("INSERT INTO CUSTOMERS (name,phone,email)" +
16 "VALUES ('NETANEL', 05555555,'SADF@GMAIL')");
17 statement.execute("INSERT INTO CUSTOMERS (name,phone,email)" +
18 "VALUES ('BAR', 05554646,'RTGDG@GMAIL')");
19 statement.execute("INSERT INTO CUSTOMERS (name,phone,email)" +
20 "VALUES ('TOMER', 055646541,'ASDQWE@GMAIL')");
21 statement.execute("INSERT INTO CUSTOMERS (name,phone,email)" +
22 "VALUES ('LEIZY', 064646231,'ASD@GMAIL')");
23```