Package de.fuberlin.wiwiss.d2rq.sql

Examples of de.fuberlin.wiwiss.d2rq.sql.SelectStatementBuilder


    requiredProjections.add(downloadMap.getContentDownloadColumn());
    requiredProjections.addAll(mediaTypeValueMaker.projectionSpecs());
    newRelation.project(requiredProjections);
    newRelation.limit(1);
    Relation filteredRelation = newRelation.immutableSnapshot();
    SelectStatementBuilder builder = new SelectStatementBuilder(filteredRelation);
    String sql = builder.getSQLStatement();
    int contentColumn = builder.getColumnSpecs().indexOf(downloadMap.getContentDownloadColumn()) + 1;
      db = filteredRelation.database();
    Connection conn = db.connection();
    try {
      statement = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      log.debug(sql);

      db.vendor().beforeQuery(conn);
      resultSet = statement.executeQuery(sql);
      db.vendor().afterQuery(conn);
     
      if (!resultSet.next()) {
        close();
        return// 0 results
      }
      int type = resultSet.getMetaData().getColumnType(contentColumn);
      // TODO Handle Oracle BFILE type; there's some code for that already in ResultRowMap
      if (type == Types.BINARY || type == Types.VARBINARY || type == Types.LONGVARBINARY || type == Types.BLOB) {
        resultStream = resultSet.getBinaryStream(contentColumn);
        if (resultSet.wasNull()) {
          resultStream = null;
        }
      } else {
        String s = resultSet.getString(contentColumn);
        if (!resultSet.wasNull()) {
          resultStream = new ByteArrayInputStream(s.getBytes());
        }
      }
      mediaType = mediaTypeValueMaker.makeValue(
          ResultRowMap.fromResultSet(resultSet, builder.getColumnSpecs(), db));
    } catch (SQLException ex) {
      throw new D2RQException(ex);
    }
  }
View Full Code Here


  private QueryIterTableSQL(Relation relation,
      Collection<BindingMaker> bindingMakers, ExecutionContext execCxt) {
    super(execCxt);
    this.bindingMakers = bindingMakers;
    SelectStatementBuilder builder = new SelectStatementBuilder(relation);
    wrapped = new SQLIterator(
        builder.getSQLStatement(), builder.getColumnSpecs(), relation.database());
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.sql.SelectStatementBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.