Ajout de la fin d'une partie avec ajout dans la BDD

This commit is contained in:
2024-11-24 00:46:22 +01:00
parent 084a850749
commit 3f06f179a5
5 changed files with 95 additions and 5 deletions

View File

@@ -80,6 +80,20 @@ public class Database {
return seed;
}
public void addScore(String username, long seriesId, int score) throws SQLException {
String insertQuery = "INSERT INTO Scores (username, series_id, score) VALUES (?, ?, ?)";
try (PreparedStatement stmt = this.database.prepareStatement(insertQuery)) {
stmt.setString(1, username);
stmt.setLong(2, seriesId);
stmt.setInt(3, score);
stmt.executeUpdate();
} catch (SQLException e) {
System.err.println("Erreur lors de l'ajout du score: " + e.getMessage());
throw e;
}
}
public void addCustomSeed(String name, long customSeed) throws SQLException {
// Vérifier si la seed existe déjà
String checkQuery = "SELECT COUNT(*) FROM Series WHERE series_id = ?";