Esempio n. 1
0
 public void delete() throws SQLException {
   Connection databaseConnection = server.getDatabaseConnection();
   try (PreparedStatement statement =
       databaseConnection.prepareStatement("DELETE FROM `game` WHERE `uuid` = ?")) {
     statement.setString(1, getUUID().toString());
     statement.executeUpdate();
   } catch (SQLException exception) {
     server.getLogger().log(SEVERE, "Failed to delete game", exception);
   } finally {
     databaseConnection.close();
   }
 }
Esempio n. 2
0
 public void update() throws SQLException {
   Connection databaseConnection = server.getDatabaseConnection();
   try (PreparedStatement statement =
       databaseConnection.prepareStatement(
           "UPDATE `game` SET `player1_uuid` = ?, `player2_uuid` = ?, `winner_uuid` = ?, `timestamp` = ? WHERE `uuid` = ?")) {
     statement.setString(1, getPlayer1().getUUID().toString());
     statement.setString(2, getPlayer2().getUUID().toString());
     statement.setString(3, getWinner().getUUID().toString());
     statement.setLong(4, getTimestamp());
     statement.setString(5, getUUID().toString());
     statement.executeUpdate();
   } catch (SQLException exception) {
     server.getLogger().log(SEVERE, "Failed to update game", exception);
   } finally {
     databaseConnection.close();
   }
 }
Esempio n. 3
0
 public void insert() throws SQLException {
   Connection databaseConnection = server.getDatabaseConnection();
   try (PreparedStatement statement =
       databaseConnection.prepareStatement(
           "INSERT INTO `game`(`uuid`, `player1_uuid`, `player2_uuid`, `winner_uuid`, `timestamp`) VALUES(?, ?, ?, ?, ?)")) {
     statement.setString(1, getUUID().toString());
     statement.setString(2, getPlayer1().getUUID().toString());
     statement.setString(3, getPlayer2().getUUID().toString());
     statement.setString(4, getWinner().getUUID().toString());
     statement.setLong(5, getTimestamp());
     statement.executeUpdate();
   } catch (SQLException exception) {
     server.getLogger().log(SEVERE, "Failed to insert game", exception);
   } finally {
     databaseConnection.close();
   }
 }