Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static CompletableFuture<Integer> getPlayerData(final File dataFolder, final String searchName, final ExecutorService service, final ExceptionHandler handler) {
- final CompletableFuture<Integer> completableFuture = new CompletableFuture<>();
- service.submit(() -> {
- try (final Connection connection = getDatabaseConnection(dataFolder)) {
- final String SQL = "SELECT flags FROM safechat_data WHERE username = " + searchName + ";";
- try (final PreparedStatement preparedStatement = connection.prepareStatement(SQL)) {
- preparedStatement.setString(1, searchName);
- try (final ResultSet resultSet = preparedStatement.executeQuery()) {
- final int flag = resultSet.getInt("flags");
- completableFuture.complete(flag);
- }
- }
- } catch (final SQLException e) {
- handler.handle(e);
- }
- });
- return completableFuture;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement