db #1

Merged
PBS2H21AKA merged 4 commits from db into main 2022-12-20 15:24:59 +01:00
3 changed files with 13 additions and 1 deletions
Showing only changes of commit 83507bef98 - Show all commits

View File

@ -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{

View File

@ -18,6 +18,7 @@ public class HelloApplication extends Application {
}
public static void main(String[] args) {
Database.init();
Database.createDb();
Database.fillSampleDb();
Database.printSampleQuery();