diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/Database.java b/src/main/java/com/bib/essensbestellungsverwaltung/Database.java index 19e3951..452b21f 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/Database.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/Database.java @@ -1,9 +1,20 @@ package com.bib.essensbestellungsverwaltung; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; import java.sql.*; public class Database { - private static final String dbLocation = "jdbc:sqlite:"+Database.class.getResource("database/database.db"); + private static final String dbLocation = "jdbc:sqlite:"+Path.of("").toAbsolutePath()+"/database.db"; + protected static void init(){ + File db = new File(Path.of("").toAbsolutePath()+"/database.db"); + try { + db.createNewFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } protected static Connection connect(){ Connection conn = null; try{ diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/HelloApplication.java b/src/main/java/com/bib/essensbestellungsverwaltung/HelloApplication.java index dcab265..60c6057 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/HelloApplication.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/HelloApplication.java @@ -18,6 +18,7 @@ public class HelloApplication extends Application { } public static void main(String[] args) { + Database.init(); Database.createDb(); Database.fillSampleDb(); Database.printSampleQuery(); diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/database/database.db b/src/main/resources/com/bib/essensbestellungsverwaltung/database/database.db deleted file mode 100644 index e69de29..0000000