Snippets

Summerfeeling xyLLA: Untitled snippet

Created by Summerfeeling
PetSQL.pool.execute(() -> {
            PreparedStatement remove = null;
            PreparedStatement add = null;

            try {
                remove = getConnection().prepareStatement("DELETE FROM pets WHERE uuid=?");
                remove.setString(1, player.getUniqueId().toString());
                remove.executeUpdate();
                for (Pet pet : pets) {
                    add = getConnection().prepareStatement("INSERT INTO pets(uuid,pet) VALUES (?,?)");
                    add.setString(1, player.getUniqueId().toString());
                    add.setString(2, MyPet.petToJSON(pet));
                    add.executeUpdate();
                }
            } catch (SQLException e) {
                System.err.println("Could not set pets for " + player.getName());
            } finally {
                PetSQL.closeResources(null, remove);
                PetSQL.closeResources(null, add);
            }
        });

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.