Package net.sf.jsqlparser.statement.select

Examples of net.sf.jsqlparser.statement.select.Select


            if (update.isUseColumnsBrackets()) {
                buffer.append(")");
            }
            buffer.append(" = ");
            buffer.append("(");
            Select select = update.getSelect();
            select.getSelectBody().accept(selectVisitor);
            buffer.append(")");
        }

        if (update.getFromItem() != null) {
            buffer.append(" FROM ").append(update.getFromItem());
View Full Code Here


    }
    return buildSelectFromTableAndSelectItems(table, list);
  }
 
  public static Select buildSelectFromTableAndSelectItems(Table table, SelectItem ... selectItems) {
    Select select = new Select();
    PlainSelect body = new PlainSelect();
    body.addSelectItems(selectItems);
    body.setFromItem(table);
    select.setSelectBody(body);
    return select;
  }
View Full Code Here

    public ResultSet executeQuery(String sql) throws SQLException {
        try {
            if (sql.contains("count(*)")) {
                return this.handleSelectCount(sql);
            } else {
                Select select = (Select) this.parserManager.parse(new StringReader(sql));
                String origDomain = ((PlainSelect) select.getSelectBody()).getFromItem().toString();
                String domain = this.getReadTableName(((PlainSelect) select.getSelectBody()).getFromItem());
                sql = sql.replaceAll(origDomain, SimpleDBUtils.quoteName(domain));
                SelectRequest selectRequest = new SelectRequest(sql);
                List<Item> items = this.connection.getSimpleDB().select(selectRequest)
                        .getItems();
                return getSimpleDBResultSet(domain, items);
View Full Code Here

    protected ResultSet getSimpleDBResultSet(String domain, List<Item> items) {
        return new SimpleDBResultSet(this.connection, items, domain);
    }

    private ResultSet handleSelectCount(final String sql) throws JSQLParserException {
        final Select select = (Select) this.parserManager.parse(new StringReader(sql));
        String domain = this.getReadTableName(((PlainSelect) select.getSelectBody()).getFromItem());
        final int count = connection.getSimpleDB().domainMetadata(
                new DomainMetadataRequest(domain)).getItemCount();
        return getSimpleDBResultSet(domain, new ArrayList<Item>(Collections
                .nCopies(1, new Item("", new ArrayList<Attribute>(Collections.nCopies(1,
                new Attribute("count", Integer.toString(count))))))));
View Full Code Here

    }
   
    public ResultSet executeQuery() throws SQLException {
        try {
          log.info("select stmt made for PreparedStmt: " + this.sql);
            Select select = (Select) this.parserManager.parse(new StringReader(sql));
           
            int qCount = StringUtils.countMatches(sql, "?");           
            for(int x = 0; x < qCount; x++){
              String value = this.args.get(x);
              this.sql = this.sql.replaceFirst("\\?", SimpleDBUtils.quoteValue(value));
            }
           
            log.info("after replacing ?'s, new sql is : " + this.sql);
           
            String origDomain = ((PlainSelect) select.getSelectBody()).getFromItem().toString();
            String domain =((PlainSelect) select.getSelectBody()).getFromItem().toString();
            sql = sql.replaceAll(origDomain, SimpleDBUtils.quoteName(domain));
            SelectRequest selectRequest = new SelectRequest(sql);
            List<Item> items = this.connection.getSimpleDB().select(selectRequest)
                    .getItems();
            return getSimpleDBResultSet(domain, items);
View Full Code Here

TOP

Related Classes of net.sf.jsqlparser.statement.select.Select

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.