From 83507bef98dd9a7f048f08291c879aefc3ac555b Mon Sep 17 00:00:00 2001 From: Malte Schulze Hobeling Date: Tue, 13 Dec 2022 03:35:52 +0100 Subject: [PATCH] made program executable --- .../bib/essensbestellungsverwaltung/Database.java | 13 ++++++++++++- .../HelloApplication.java | 1 + .../database/database.db | 0 3 files changed, 13 insertions(+), 1 deletion(-) delete mode 100644 src/main/resources/com/bib/essensbestellungsverwaltung/database/database.db 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