All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.matteobertozzi.easerinsights.jdbc.sqlx.impl.SqlRowImpl Maven / Gradle / Ivy

The newest version!
package io.github.matteobertozzi.easerinsights.jdbc.sqlx.impl;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import io.github.matteobertozzi.easerinsights.jdbc.sqlx.SqlRow;

public class SqlRowImpl implements SqlRow {
  private final PreparedStatement stmt;
  private final T builder;
  private int index;

  public SqlRowImpl(final T builder, final PreparedStatement stmt) {
    this.stmt = stmt;
    this.builder = builder;
    this.index = 0;
  }

  @Override
  public SqlRow addBool(final boolean value) throws SQLException {
    stmt.setBoolean(index++, value);
    return this;
  }

  @Override
  public SqlRow addShort(final short value) throws SQLException {
    stmt.setShort(index++, value);
    return this;
  }

  @Override
  public SqlRow addInt(final int value) throws SQLException {
    stmt.setInt(index++, value);
    return this;
  }

  @Override
  public SqlRow addLong(final long value) throws SQLException {
    stmt.setLong(index++, value);
    return this;
  }

  @Override
  public SqlRow addBytes(final byte[] value) throws SQLException {
    stmt.setBytes(index++, value);
    return this;
  }

  @Override
  public SqlRow addString(final String value) throws SQLException {
    stmt.setString(index++, value);
    return this;
  }

  @Override
  public T bind() {
    return builder;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy