diff --git a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin index e9b7418..24b5e11 100644 Binary files a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin and b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin differ diff --git a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock index a4e68c4..cd21a7e 100644 Binary files a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock and b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock differ diff --git a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin index 85bdbf6..dd02514 100644 Binary files a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin and b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin differ diff --git a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock index 2367c58..9b96131 100644 Binary files a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock and b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock differ diff --git a/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 6da2fff..defe30f 100644 Binary files a/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class b/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class index ab916e9..1af60f5 100644 Binary files a/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class and b/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class differ diff --git a/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar b/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar index dd23200..e611ded 100644 Binary files a/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar and b/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar differ diff --git a/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin b/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin index a270af8..69382fa 100644 Binary files a/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin and b/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java b/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java index 46d7273..425a61e 100644 --- a/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java +++ b/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java @@ -15,6 +15,8 @@ import javafx.stage.Stage; public class HappyBirdMain extends Application { + MariaDB datenbank = new MariaDB(); + /*Panes erstellen und zuweisen*/ private final Pane pane = new Pane(); private final Pane pause = new Pane(); diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/MariaDB.java b/Happy_Bird/src/main/java/com/example/happy_bird/MariaDB.java index c6295f4..aa23d1c 100644 --- a/Happy_Bird/src/main/java/com/example/happy_bird/MariaDB.java +++ b/Happy_Bird/src/main/java/com/example/happy_bird/MariaDB.java @@ -13,10 +13,36 @@ public class MariaDB public MariaDB() { + /* + username="root"; + pw="HappyBird1"; + url="jdbc:mariadb://localhost:3306/happybird"; + driver="org.mariadb.jdbc.Driver"; try { - con = DriverManager.getConnection("jdbc:mariadb://localhost:3306/DB?user=root&password=HappyBird1"); - } catch (SQLException e) { + Class.forName(driver); + con=DriverManager.getConnection(url, username, pw); + st= (Statement) con.createStatement(); + System.out.println("Connection is successful"); + } catch (Exception e) { + System.out.println("Fehler in der Verbindung"); e.printStackTrace(); } + + */ + + try + { + con = DriverManager.getConnection("jdbc:mariadb://localhost:3306/happybird?user=root&password=HappyBird1"); + st= (Statement) con.createStatement(); + driver="org.mariadb.jdbc.Driver"; + System.out.println("Connection is successful"); + } + catch (Exception e) + { + System.out.println("Fehler in der Verbindung"); + e.printStackTrace(); + } + + } } diff --git a/SQL-Queries.txt b/SQL-Queries.txt new file mode 100644 index 0000000..b4ba033 --- /dev/null +++ b/SQL-Queries.txt @@ -0,0 +1,14 @@ +SQL-Abfragen: + +Highscores: +SELECT * FROM happybirddb ORDER BY punkte DESC LIMIT 5; +Dann Ausgabe auf dem Bildschirm + +Einfügen in die DB: +INSERT INTO HappyBirdDB (name, kuerzel, punkte) VALUES ('playername', 'playerkuerzel', points); +//playername, playerkuerzel, points sind Variablen + + +Maximale Punkte des Spielers: +SELECT MAX(punkte) FROM happybirddb WHERE kuerzel = 'playerkuerzel'; +