Merge Hintergrund, Datenbank
This commit is contained in:
commit
7f359cb01f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5
Happy_Bird/.idea/jarRepositories.xml
generated
5
Happy_Bird/.idea/jarRepositories.xml
generated
@ -16,5 +16,10 @@
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -9,6 +9,7 @@ version '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
ext {
|
||||
@ -36,6 +37,7 @@ dependencies {
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
|
||||
implementation 'org.mariadb.jdbc:mariadb-java-client:2.1.2'
|
||||
}
|
||||
|
||||
test {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import java.beans.Statement;
|
||||
import java.sql.*;
|
||||
public class MariaDB
|
||||
{
|
||||
@ -13,10 +12,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=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();
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
14
SQL-Queries.txt
Normal file
14
SQL-Queries.txt
Normal file
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user