db #1
@ -1,9 +1,20 @@
|
|||||||
package com.bib.essensbestellungsverwaltung;
|
package com.bib.essensbestellungsverwaltung;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
|
||||||
public class Database {
|
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(){
|
protected static Connection connect(){
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try{
|
try{
|
||||||
|
@ -18,6 +18,7 @@ public class HelloApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Database.init();
|
||||||
Database.createDb();
|
Database.createDb();
|
||||||
Database.fillSampleDb();
|
Database.fillSampleDb();
|
||||||
Database.printSampleQuery();
|
Database.printSampleQuery();
|
||||||
|
Loading…
Reference in New Issue
Block a user