2022-11-15 14:26:06 +01:00
|
|
|
package com.bib.essensbestellungsverwaltung;
|
|
|
|
|
|
|
|
import javafx.application.Application;
|
|
|
|
import javafx.fxml.FXMLLoader;
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
import javafx.stage.Stage;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2022-11-29 22:35:12 +01:00
|
|
|
import java.sql.*;
|
2022-11-15 14:26:06 +01:00
|
|
|
|
|
|
|
public class HelloApplication extends Application {
|
2022-11-29 22:35:12 +01:00
|
|
|
private static final String dbLocation = "jdbc:sqlite:"+HelloApplication.class.getResource("database/database.db");
|
2022-11-15 14:26:06 +01:00
|
|
|
@Override
|
|
|
|
public void start(Stage stage) throws IOException {
|
|
|
|
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
|
|
|
|
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
2022-11-24 15:11:43 +01:00
|
|
|
stage.setTitle("Hello World! von Richard");
|
2022-11-15 14:26:06 +01:00
|
|
|
stage.setScene(scene);
|
|
|
|
stage.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
2022-11-29 22:45:05 +01:00
|
|
|
/* String sql = """
|
2022-11-29 22:35:12 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS user (
|
|
|
|
id integer PRIMARY KEY,
|
|
|
|
name text);""";
|
|
|
|
String sql2 = "SELECT * FROM user WHERE id > ?";
|
|
|
|
String sql3 = "INSERT INTO user (id,name) VALUES (1,'test1')";
|
|
|
|
try(Connection conn = connect();
|
|
|
|
Statement stmt = conn.createStatement()){
|
2022-11-29 22:45:05 +01:00
|
|
|
stmt.execute(sql);
|
|
|
|
stmt.execute(sql3);
|
2022-11-29 22:35:12 +01:00
|
|
|
PreparedStatement pstmt = conn.prepareStatement(sql2);
|
2022-11-29 22:45:05 +01:00
|
|
|
pstmt.setInt(1,0);
|
2022-11-29 22:35:12 +01:00
|
|
|
ResultSet rs = pstmt.executeQuery();
|
|
|
|
while (rs.next()){
|
|
|
|
System.out.println(rs.getInt("id"));
|
|
|
|
}
|
|
|
|
}catch (SQLException e){
|
|
|
|
e.printStackTrace();
|
|
|
|
return;
|
2022-11-29 22:45:05 +01:00
|
|
|
} */
|
2022-11-15 14:26:06 +01:00
|
|
|
launch();
|
|
|
|
}
|
2022-11-29 22:35:12 +01:00
|
|
|
|
|
|
|
private static Connection connect(){
|
|
|
|
Connection conn = null;
|
|
|
|
try{
|
|
|
|
conn = DriverManager.getConnection(dbLocation);
|
|
|
|
}catch (SQLException e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return conn;
|
|
|
|
}
|
2022-11-15 14:26:06 +01:00
|
|
|
}
|