most Objects done

This commit is contained in:
2023-01-30 04:26:30 +01:00
parent a0eed3ce51
commit 81bcb44d74
15 changed files with 396 additions and 121 deletions

View File

@@ -45,7 +45,7 @@ public class Database {
* creates the initial structure of the db
*/
protected static void createDb(){
String[] sql = new String[14];
String[] sql = new String[15];
sql[0] = """
CREATE TABLE IF NOT EXISTS address (
id integer PRIMARY KEY,
@@ -157,6 +157,11 @@ public class Database {
FOREIGN KEY(food_planid) REFERENCES food_plan(id),
FOREIGN KEY(foodid) REFERENCES food(id)
);""";
sql[14] = """
CREATE TABLE IF NOT EXISTS price (
id integer PRIMARY KEY,
price integer
);""";
try(Connection conn = connect(); Statement stmt = conn.createStatement()){
for(int i = 0; i < sql.length; i++){
stmt.execute(sql[i]);
@@ -255,6 +260,9 @@ public class Database {
sqls.add("""
INSERT OR IGNORE INTO severity (id,name)
VALUES('3','Kritisch');""");
sqls.add("""
INSERT OR IGNORE INTO price (id,price)
VALUES('1','500');""");
try(Connection conn = connect(); Statement stmt = conn.createStatement()){
for (String sql : sqls) {
stmt.execute(sql);