Creates a list of placeholders for use in a PreparedStatement

@param length number of placeholders
@return String of placeholders, seperated by comma
15895
private static String preparePlaceHolders(int length) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; ) {
            builder.append("?");
            if (++i < length) {
                builder.append(",");
            }
        }
        return builder.toString();
    }
11572
protected function prepareArrayPlaceholders($sql)
    {
        if (!count($this->arrays)) {
            return $sql;
        }
        foreach ($this->arrays as $placeholder => $array) {
            if (strpos($sql, $placeholder) === false) {
                continue;
            }

            $placeholders = [];
            $cnt = count($array);
            for ($i = 0; $i < $cnt; $i++) {
                $placeholders[] = $placeholder . $i;
            }
            $sql = str_replace($placeholder, '(' . implode(', ', $placeholders) . ')', $sql);
        }

        return $sql;
    }
749097
@SuppressWarnings("unchecked")
	public static List<String> allStrings(PreparedStatement stmt) throws SQLException {
		return (List<String>) all(stmt, String.class);
	}
101965
static public function create_list($string=NULL, $addThis=NULL, $delimiter=", ") {
		if(count(func_get_args()) > 3) {
			trigger_error(__METHOD__ .": argument 'useSqlQuotes' is deprecated and no longer utilized");
		}
		if(strlen($string)) {
			$retVal = $string . $delimiter . $addThis;
		}
		else {
			$retVal = $addThis;
		}
	
		return($retVal);
	}
689770
public @NotNull QueryBuilder appendPlaceholders(int count) {
        if (count <= 0) throw new IllegalArgumentException("count must be positive, but was: " + count);

        query.append('?');
        for (int i = 1; i < count; i++)
            query.append(",?");

        return this;
    }

    /**
     * Adds placeholders for all elements of collection and then adds then values
     * of collection itself.
     */
    public @NotNull QueryBuilder appendPlaceholders(@NotNull Collection<?> args) {
        appendPlaceholders(args.size());
        addArguments(args);

        return this;
    }

    /**
     * Is the query string empty?
     */
    public boolean isEmpty() {
       return query.length() == 0;
    }

    /**
     * Does this query have any arguments?
     */
    public boolean hasArguments() {
        return !arguments.isEmpty();
    }

    /**
     * Adds an argument to this query.
     */
    public @NotNull QueryBuilder addArgument(@Nullable Object argument) {
        arguments.add(argument);
        return this;
    }

    /**
     * Adds given arguments to this query.
     */
    public @NotNull QueryBuilder addArguments(Object... args) {
        return addArguments(asList(args));
    }

    /**
     * Adds given arguments to this query.
     */
    public @NotNull QueryBuilder addArguments(@NotNull Collection<?> args) {
        arguments.addAll(args);
        return this;
    }

    /**
     * Builds an SQL query from the current state of this builder.
     *
     * @throws IllegalStateException if the builder is empty
     */
    public @NotNull SqlQuery build() {
        if (query.length() == 0)
            throw new IllegalStateException("empty query");

        return SqlQuery.query(query.toString(), new ArrayList<>(arguments));
    }
}
481855
public static String adHocSQLStringFromPlannedStatement(AdHocPlannedStatement statement, Object[] userparams) {
        final int MAX_PARAM_LINE_CHARS = 120;

        StringBuilder sb = new StringBuilder();
        String sql = new String(statement.sql, Charsets.UTF_8);
        sb.append(sql);

        Object[] params = paramsForStatement(statement, userparams);
        // convert params to strings of a certain max length
        for (int i = 0; i < params.length; i++) {
            Object param = params[i];

            String paramLineStr = String.format("    Param %d: %s", i, param.toString());
            // trim param line if it's silly long
            if (paramLineStr.length() > MAX_PARAM_LINE_CHARS) {
                paramLineStr = paramLineStr.substring(0, MAX_PARAM_LINE_CHARS - 3);
                paramLineStr += "...";
            }

            sb.append('\n').append(paramLineStr);
        }

        return sb.toString();
    }
1283470
public PreparedStatement prepareStatement(final String _sql,
                                              final String[] _strings)
        throws SQLException
    {
        return getConnection().prepareStatement(_sql, _strings);
    }
1084153
def get_placeholder_formats_list(self, format_string):
        
        placeholders = []
        # Tokenize the format string and process them
        for token in self.tokens(format_string):
            if token.group("placeholder"):
                placeholders.append((token.group("key"), token.group("format")))
        return placeholders
1210204
public static String generateMixString(int length) {
		StringBuffer sb = new StringBuffer();
		Random random = new Random();
		for (int i = 0; i < length; i++) {
			sb.append(allChar.charAt(random.nextInt(letterChar.length())));
		}
		return sb.toString();
	}
196892
function wrapPlaceholders(placeholders) {
  const keys = Object.keys(placeholders);
  const wrappedPlaceholders = {};

  for (let i = 0; i < keys.length; i++) {
    wrappedPlaceholders['<'+keys[i]+'>'] = placeholders[keys[i]];
  }

  return wrappedPlaceholders;
}
986061
static String format(String template, Object... args) {
        template = String.valueOf(template); // null -> "null"

        if (N.isNullOrEmpty(args)) {
            return template;
        }

        // start substituting the arguments into the '%s' placeholders
        final StringBuilder sb = Objectory.createStringBuilder(template.length() + 16 * args.length);
        int templateStart = 0;
        int i = 0;

        String placeholder = "{}";
        int placeholderStart = template.indexOf(placeholder);

        if (placeholderStart < 0) {
            placeholder = "%s";
            placeholderStart = template.indexOf(placeholder);
        }

        while (placeholderStart >= 0 && i < args.length) {
            sb.append(template, templateStart, placeholderStart);
            sb.append(N.toString(args[i++]));
            templateStart = placeholderStart + 2;
            placeholderStart = template.indexOf(placeholder, templateStart);
        }

        sb.append(template, templateStart, template.length());

        // if we run out of placeholders, append the extra args in square braces
        if (i < args.length) {
            sb.append(" [");
            sb.append(N.toString(args[i++]));
            while (i < args.length) {
                sb.append(", ");
                sb.append(N.toString(args[i++]));
            }
            sb.append(']');
        }

        final String result = sb.toString();

        Objectory.recycle(sb);

        return result;
    }
635220
protected ArrayList<String> reflect() {
        Map<String, SQLStmt> stmtMap = new HashMap<>();

        // fill in the sql for single statement procs
        if (m_catProc.getHasjava() == false) {
            try {
                for (int i = 0; i < m_catProc.getStatements().size(); i++) {
                    Statement statement = m_catProc.getStatements().get(VoltDB.ANON_STMT_NAME + String.valueOf(i));
                    String s = statement.getSqltext();
                    SQLStmt stmt = new SQLStmt(s);

                    QueuedSQL singleStmt = new QueuedSQL();
                    singleStmt.stmt = stmt;
                    m_sqlStmts.add(singleStmt);
                    stmtMap.put(VoltDB.ANON_STMT_NAME + String.valueOf(i), stmt);

                    int numParams = m_catProc.getParameters().size();
                    m_paramTypes = new Class<?>[numParams];

                    for (ProcParameter param : m_catProc.getParameters()) {
                        VoltType type = VoltType.get((byte) param.getType());
                        if (param.getIsarray()) {
                            m_paramTypes[param.getIndex()] = type.vectorClassFromType();
                            continue;
                        }
                        // Paul doesn't understand why single-statement procedures
                        // need to have their input parameter types widened here.
                        // Is it not better to catch too-wide values in the ProcedureRunner
                        // (ParameterConverter.tryToMakeCompatible) before falling through to the EE?
                        if (type == VoltType.INTEGER) {
                            type = VoltType.BIGINT;
                        } else if (type == VoltType.SMALLINT) {
                            type = VoltType.BIGINT;
                        } else if (type == VoltType.TINYINT) {
                            type = VoltType.BIGINT;
                        } else if (type == VoltType.NUMERIC) {
                            type = VoltType.FLOAT;
                        }

                        m_paramTypes[param.getIndex()] = type.classFromType();
                    }
                }
            } catch (Exception e) {
                // shouldn't throw anything outside of the compiler
                e.printStackTrace();
            }
        } else {
            // this is where, in the case of java procedures, m_procMethod is set
            for (final Method m : m_procedure.getClass().getDeclaredMethods()) {
                String name = m.getName();
                if (name.equals("run")) {
                    if (Modifier.isPublic(m.getModifiers()) == false) {
                        continue;
                    }
                    m_procMethod = m;
                    m_paramTypes = m.getParameterTypes();
                    break;
                }
            }

            if (m_procMethod == null) {
                throw new RuntimeException("No \"run\" method found in: " + m_procedure.getClass().getName());
            }
            // iterate through the fields and deal with sql statements
            try {
                stmtMap = ProcedureCompiler.getValidSQLStmts(null, m_procedureName, m_procedure.getClass(), m_procedure,
                        true);
            } catch (Exception e) {
                // shouldn't happen here because it passed the compiler
                VoltDB.crashLocalVoltDB("getValidSQLStmts threw exception during ProcedureRunner loading", true, e);
            }
        }

        ArrayList<String> stmtNames = new ArrayList<String>(stmtMap.entrySet().size());
        for (final Entry<String, SQLStmt> entry : stmtMap.entrySet()) {
            String name = entry.getKey();
            stmtNames.add(name);
            // Label the SQLStmts with its variable name.
            // This is useful for multi-partition stored procedures.
            // When a statement is sent to another site for execution,
            // that SP site can use this name to find the correct place to
            // update the statistics numbers.
            entry.getValue().setStmtName(name);
            Statement s = m_catProc.getStatements().get(name);
            if (s != null) {
                /*
                 * Cache all the information we need about the statements in this stored
                 * procedure locally instead of pulling them from the catalog on
                 * a regular basis.
                 */
                SQLStmt stmt = entry.getValue();
                // done in a static method in an abstract class so users don't call it
                initSQLStmt(stmt, s);
                //LOG.fine("Found statement " + name);
            }
        }
        return stmtNames;
    }
1114314
public static String createSequence(char c, int length) {
        if (length < 0) length = 1;

        StringBuffer buf = new StringBuffer(length);
        for (; length > 0; length--) {
            buf.append(c);
        }
        return buf.toString();
    }
944517
String[] getTableRightsArray() {

        if (isFull) {
            return new String[] {
                Tokens.T_SELECT, Tokens.T_INSERT, Tokens.T_UPDATE,
                Tokens.T_DELETE, Tokens.T_REFERENCES
            };
        }

        HsqlArrayList list  = new HsqlArrayList();
        String[]      array = new String[list.size()];

        if (isFullSelect) {
            list.add(Tokens.T_SELECT);
        }

        if (isFullInsert) {
            list.add(Tokens.T_INSERT);
        }

        if (isFullUpdate) {
            list.add(Tokens.T_UPDATE);
        }

        if (isFullDelete) {
            list.add(Tokens.T_DELETE);
        }

        if (isFullReferences) {
            list.add(Tokens.T_REFERENCES);
        }

        if (isFullTrigger) {
            list.add(Tokens.T_TRIGGER);
        }

        list.toArray(array);

        return array;
    }
530772
private void parseValues(final InsertStatement insertStatement) {
        Optional<InsertValuesToken> insertValuesToken = insertStatement.findSQLToken(InsertValuesToken.class);
        Preconditions.checkState(insertValuesToken.isPresent());
        insertStatement.getSQLTokens().remove(insertValuesToken.get());
        insertStatement.addSQLToken(new InsertValuesToken(insertValuesToken.get().getStartIndex()));
        do {
            lexerEngine.accept(Symbol.LEFT_PAREN);
            List<SQLExpression> sqlExpressions = new LinkedList<>();
            int count = 0;
            do {
                sqlExpressions.add(basicExpressionParser.parse(insertStatement));
                skipsDoubleColon();
                count++;
            } while (lexerEngine.skipIfEqual(Symbol.COMMA));
            Collection<String> columnNames = new ArrayList<>(insertStatement.getColumnNames());
            Optional<String> generateKeyColumnName = shardingRule.findGenerateKeyColumnName(insertStatement.getTables().getSingleTableName());
            if (generateKeyColumnName.isPresent() && count != insertStatement.getColumnNames().size()) {
                columnNames.remove(generateKeyColumnName.get());
            }
            count = 0;
            AndCondition andCondition = new AndCondition();
            String tableName = insertStatement.getTables().getSingleTableName();
            for (String each : columnNames) {
                SQLExpression sqlExpression = sqlExpressions.get(count);
                if (shardingRule.isShardingColumn(each, tableName)) {
                    if (!(sqlExpression instanceof SQLNumberExpression || sqlExpression instanceof SQLTextExpression || sqlExpression instanceof SQLParameterMarkerExpression)) {
                        throw new SQLParsingException("INSERT INTO can not support complex expression value on sharding column '%s'.", each);
                    }
                    andCondition.getConditions().add(new Condition(new Column(each, tableName), sqlExpression));
                }
                count++;
            }
            lexerEngine.accept(Symbol.RIGHT_PAREN);
            InsertValue insertValue = new InsertValue(sqlExpressions);
            insertStatement.getValues().add(insertValue);
            insertStatement.getRouteConditions().getOrCondition().getAndConditions().add(andCondition);
        } while (lexerEngine.skipIfEqual(Symbol.COMMA));
    }
974377
public List<String> getStringList(final String param) {
    return get(param, new StringToStringList(","),
        new AlwaysValid<List<String>>(),
        "comma-separated list of strings");
  }
196188
static List<JQLPlaceHolder> removeDynamicPlaceHolder(List<JQLPlaceHolder> placeHolders) {
		List<JQLPlaceHolder> result = new ArrayList<>();

		for (JQLPlaceHolder item : placeHolders) {
			if (item.type != JQLPlaceHolderType.DYNAMIC_SQL) {
				result.add(item);
			}
		}

		return result;
	}