Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private PreparedStatement fill(PreparedStatement ps, Object... args) throws SQLException {
- for (int i = 0; i < args.length; i++)
- ps.setObject(i + 1, args[i]);
- return ps;
- }
- public void select(@Language("SQL") String sql, SelectHandler handler, Object... args) {
- if (this.connection == null)
- return;
- if (handler == null)
- handler = rs -> {};
- try (PreparedStatement ps = this.fill(this.connection.prepareStatement(sql), args)) {
- try (ResultSet rs = ps.executeQuery()) {
- handler.debug(sql + " " + Arrays.toString(args));
- handler.execute(rs);
- }
- this.stats.querySelect++;
- } catch (Exception e) {
- this.handleException(e, handler);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement