Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private ExecutorService executor = GameAPI.getGameAPI().getDatabaseHandler().getExecutor();
- private Connection connection = GameAPI.getGameAPI().getDatabaseHandler().getConnections();
- private PreparedStatement statement;
- private int index;
- public StatementManager(String sql) throws SQLException {
- statement = connection.prepareStatement(sql);
- index = 0;
- }
- public StatementManager string(String sql) throws SQLException {
- index++;
- statement.setString(index, sql);
- return this;
- }
- public StatementManager integer(int sql) throws SQLException {
- index++;
- statement.setInt(index, sql);
- return this;
- }
- public PreparedStatement update() throws SQLException {
- statement.executeUpdate();
- return statement;
- }
- public ResultSet query() throws SQLException {
- ResultSet resultSet = statement.executeQuery();
- return resultSet;
- }
- public PreparedStatement asyncUpdate() {
- executor.submit(() -> {
- try {
- statement.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- });
- return statement;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement