Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. private ExecutorService executor = GameAPI.getGameAPI().getDatabaseHandler().getExecutor();
  2. private Connection connection = GameAPI.getGameAPI().getDatabaseHandler().getConnections();
  3. private PreparedStatement statement;
  4. private int index;
  5.  
  6. public StatementManager(String sql) throws SQLException {
  7. statement = connection.prepareStatement(sql);
  8. index = 0;
  9. }
  10.  
  11. public StatementManager string(String sql) throws SQLException {
  12. index++;
  13. statement.setString(index, sql);
  14. return this;
  15. }
  16.  
  17. public StatementManager integer(int sql) throws SQLException {
  18. index++;
  19. statement.setInt(index, sql);
  20. return this;
  21. }
  22.  
  23. public PreparedStatement update() throws SQLException {
  24. statement.executeUpdate();
  25. return statement;
  26. }
  27.  
  28. public ResultSet query() throws SQLException {
  29. ResultSet resultSet = statement.executeQuery();
  30. return resultSet;
  31. }
  32.  
  33. public PreparedStatement asyncUpdate() {
  34.  
  35. executor.submit(() -> {
  36.  
  37. try {
  38. statement.executeUpdate();
  39. } catch (SQLException e) {
  40. e.printStackTrace();
  41. }
  42.  
  43. });
  44.  
  45. return statement;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement