db #1
@ -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{
|
||||
|
@ -18,6 +18,7 @@ public class HelloApplication extends Application {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Database.init();
|
||||
Database.createDb();
|
||||
Database.fillSampleDb();
|
||||
Database.printSampleQuery();
|
||||
|
Loading…
Reference in New Issue
Block a user