Advertisement
thevipershowita

getPlayerData.java

May 13th, 2020
1,536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. public static CompletableFuture<Integer> getPlayerData(final File dataFolder, final String searchName, final ExecutorService service, final ExceptionHandler handler) {
  2.         final CompletableFuture<Integer> completableFuture = new CompletableFuture<>();
  3.         service.submit(() -> {
  4.             try (final Connection connection = getDatabaseConnection(dataFolder)) {
  5.                 final String SQL = "SELECT flags FROM safechat_data WHERE username = " + searchName + ";";
  6.                 try (final PreparedStatement preparedStatement = connection.prepareStatement(SQL)) {
  7.                     preparedStatement.setString(1, searchName);
  8.                     try (final ResultSet resultSet = preparedStatement.executeQuery()) {
  9.                         final int flag = resultSet.getInt("flags");
  10.                         completableFuture.complete(flag);
  11.                     }
  12.                 }
  13.             } catch (final SQLException e) {
  14.                 handler.handle(e);
  15.             }
  16.         });
  17.         return completableFuture;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement