Code example for Connection

Methods: prepareStatement

0
    this.sql = sql;
    this.params = params;
  } 
 
  public PreparedStatement asPreparedStatement(Connection conn) throws SQLException {
    PreparedStatement stmt = conn.prepareStatement(sql);
    for (int i = 0; i < params.size(); i++) {
      SqlParameter p = params.get(i);
      if (p.sqlType == null) {
        stmt.setObject(i + 1, p.value);
      } else { 
        stmt.setObject(i + 1, p.value, p.sqlType);
      } 
    } 
    return stmt;
  } 
 
}