{@inheritDoc}

@see jp.co.future.uroborosql.filter.SqlFilter#doPreparedStatement(jp.co.future.uroborosql.context.SqlContext, java.sql.PreparedStatement)
174659
@Override
	public PreparedStatement doPreparedStatement(final SqlContext sqlContext, final PreparedStatement preparedStatement)
			throws SQLException {
		if (getFilters().isEmpty()) {
			return preparedStatement;
		}
		PreparedStatement ps = preparedStatement;
		for (final SqlFilter filter : getFilters()) {
			ps = filter.doPreparedStatement(sqlContext, ps);
		}
		return ps;
	}
680645
public static CallableStatement prepareCall(Connection conn, String sql, Object... params) throws SQLException {
		Assert.notBlank(sql, "Sql String must be not blank!");

		sql = sql.trim();
		SqlLog.INSTASNCE.log(sql, params);
		final CallableStatement call = conn.prepareCall(sql);
		fillParams(call, params);
		return call;
	}
10581
@Override
	public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
			final ResultSet resultSet) {
		LOG.debug("SQL:{} executed.", sqlContext.getSqlName());
		return resultSet;
	}
561940
public ServerSidePreparedStatement serverPrepareStatement(final String sql)
      throws SQLException {
    return new ServerSidePreparedStatement(this,
        sql,
        ResultSet.TYPE_FORWARD_ONLY,
        ResultSet.CONCUR_READ_ONLY,
        Statement.RETURN_GENERATED_KEYS);
  }
662029
protected MappedPreparedStmt<T, ID> prepareStatement(Long limit, boolean cacheStore) throws SQLException {
		List<ArgumentHolder> argList = new ArrayList<ArgumentHolder>();
		String statement = buildStatementString(argList);
		ArgumentHolder[] selectArgs = argList.toArray(new ArgumentHolder[argList.size()]);
		FieldType[] resultFieldTypes = getResultFieldTypes();
		FieldType[] argFieldTypes = new FieldType[argList.size()];
		for (int selectC = 0; selectC < selectArgs.length; selectC++) {
			argFieldTypes[selectC] = selectArgs[selectC].getFieldType();
		}
		if (!type.isOkForStatementBuilder()) {
			throw new IllegalStateException("Building a statement from a " + type + " statement is not allowed");
		}
		return new MappedPreparedStmt<T, ID>(dao, tableInfo, statement, argFieldTypes, resultFieldTypes, selectArgs,
				(databaseType.isLimitSqlSupported() ? null : limit), type, cacheStore);
	}
18217
String getPreparedStatementText(ControlBeanContext context, Method m, Object[] args) {
        StringBuilder sb = new StringBuilder();
        for (SqlFragment sf : _children) {
            sb.append(sf.getPreparedStatementText(context, m, args));
        }
        return sb.toString();
    }
926700
public String buildPreparedStatementName() {
		if (!StringUtils.hasText(preparedStatementName)) {
			preparedStatementName = getParent().buildPreparedStatementName(getName());
		}
		return preparedStatementName;
	}
985626
@Override
	public void bindParams(final PreparedStatement preparedStatement) throws SQLException {
		Parameter[] bindParameters = getBindParameters();

		Set<String> matchParams = new HashSet<>();
		int parameterIndex = 1;
		for (Parameter bindParameter : bindParameters) {
			Parameter parameter = getSqlFilterManager().doParameter(bindParameter);
			parameterIndex = parameter.setParameter(preparedStatement, parameterIndex, parameterMapperManager);
			matchParams.add(parameter.getParameterName());
		}
		// SQL上のバインドパラメータ群（bindNames）に対応する値がすべて設定されているかどうかをチェックする
		if (!matchParams.containsAll(bindNames)) {
			Set<String> missMatchParams = new LinkedHashSet<>(bindNames);
			missMatchParams.removeAll(matchParams);
			throw new ParameterNotFoundRuntimeException("Parameter " + missMatchParams.toString() + " is not bound.");
		}
	}
1328455
private int bindStatement(PreparedStatement stmt, int index, BetweenCriteria crit, ClassDescriptor cld) throws SQLException
    {
        index = bindStatementValue(stmt, index, crit.getAttribute(), crit.getValue(), cld);

        return bindStatementValue(stmt, index, crit.getAttribute(), crit.getValue2(), cld);
    }
94809
protected void setParameter( PreparedStatement pPreparedStatement ) throws SQLException
  {
    if( _parameters != null )
    {
      for( int i = 0; i < _parameters.size(); i++ )
      {
        pPreparedStatement.setObject( i + 1, _parameters.get( i ) );
      }
    }
  }
1262980
public static PreparedStatement bindParams(PreparedStatement pstm, Object... bindValues)
            throws SQLException {
        if (bindValues != null)
            for (int i = 0; i < bindValues.length; i++) {
                Object value = bindValues[i];
                if (value instanceof Boolean) {
                    pstm.setBoolean(i + 1, (Boolean) value);
                } else if (value instanceof Character || value instanceof String) {
                    pstm.setString(i + 1, value.toString());
                } else if (value instanceof Byte) {
                    pstm.setByte(i + 1, (Byte) value);
                } else if (value instanceof Short) {
                    pstm.setShort(i + 1, (Short) value);
                } else if (value instanceof Integer) {
                    pstm.setInt(i + 1, (Integer) value);
                } else if (value instanceof Long) {
                    pstm.setLong(i + 1, (Long) value);
                } else if (value instanceof BigInteger) {
                    pstm.setLong(i + 1, ((BigInteger) value).longValue());
                } else if (value instanceof Float) {
                    pstm.setFloat(i + 1, (Float) value);
                } else if (value instanceof Double) {
                    pstm.setDouble(i + 1, (Double) value);
                } else if (value instanceof BigDecimal) {
                    pstm.setBigDecimal(i + 1, (BigDecimal) value);
                } else if (value instanceof java.sql.Date) {
                    pstm.setDate(i + 1, (java.sql.Date) value);
                } else if (value instanceof java.sql.Time) {
                    pstm.setTime(i + 1, (java.sql.Time) value);
                } else if (value instanceof java.sql.Timestamp) {
                    pstm.setTimestamp(i + 1, (java.sql.Timestamp) value);
                } else if (value instanceof Date) {
                    pstm.setTimestamp(i + 1, new Timestamp(((Date) value).getTime()));
                } else if (value instanceof Blob) {
                    pstm.setBlob(i + 1, (Blob) value);
                } else if (value instanceof Clob) {
                    pstm.setClob(i + 1, (Clob) value);
                } else if (value instanceof byte[]) {
                    pstm.setBytes(i + 1, (byte[]) value);
                } else {
                    pstm.setObject(i + 1, value);
                }
            }
        return pstm;
    }

    /**
     * Bind parameter values to a {@link CallableStatement}.
     * 
     * @param cstm
     * @param bindValues
     * @return
     * @since 0.8.2
     * @throws SQLException
     */
    public static PreparedStatement bindParams(CallableStatement cstm, Object... bindValues)
            throws SQLException {
        if (bindValues != null)
            for (int i = 0; i < bindValues.length; i++) {
                Object value = bindValues[i];
                if (value instanceof Boolean) {
                    cstm.setBoolean(i + 1, (Boolean) value);
                } else if (value instanceof Character || value instanceof String) {
                    cstm.setString(i + 1, value.toString());
                } else if (value instanceof Byte) {
                    cstm.setByte(i + 1, (Byte) value);
                } else if (value instanceof Short) {
                    cstm.setShort(i + 1, (Short) value);
                } else if (value instanceof Integer) {
                    cstm.setInt(i + 1, (Integer) value);
                } else if (value instanceof Long) {
                    cstm.setLong(i + 1, (Long) value);
                } else if (value instanceof BigInteger) {
                    cstm.setLong(i + 1, ((BigInteger) value).longValue());
                } else if (value instanceof Float) {
                    cstm.setFloat(i + 1, (Float) value);
                } else if (value instanceof Double) {
                    cstm.setDouble(i + 1, (Double) value);
                } else if (value instanceof BigDecimal) {
                    cstm.setBigDecimal(i + 1, (BigDecimal) value);
                } else if (value instanceof java.sql.Date) {
                    cstm.setDate(i + 1, (java.sql.Date) value);
                } else if (value instanceof java.sql.Time) {
                    cstm.setTime(i + 1, (java.sql.Time) value);
                } else if (value instanceof java.sql.Timestamp) {
                    cstm.setTimestamp(i + 1, (java.sql.Timestamp) value);
                } else if (value instanceof Date) {
                    cstm.setTimestamp(i + 1, new Timestamp(((Date) value).getTime()));
                } else if (value instanceof Blob) {
                    cstm.setBlob(i + 1, (Blob) value);
                } else if (value instanceof Clob) {
                    cstm.setClob(i + 1, (Clob) value);
                } else if (value instanceof byte[]) {
                    cstm.setBytes(i + 1, (byte[]) value);
                } else {
                    cstm.setObject(i + 1, value);
                }
            }
        return cstm;
    }
53241
private PreparedStatement buildPreparedStatement(Connection connection, QueryModel queryModel)
            throws SQLException {
        PreparedStatement preparedStatement = connection.prepareStatement(buildSelectString(queryModel));

        int parameterLocation = 1;
        for (Condition condition : queryModel.getConditions()) {
            JDBCConstraint jdbcConstraint = (JDBCConstraint) condition.getConstraint();

            if (jdbcConstraint.getParameter1() != null) {
                preparedStatement.setObject(parameterLocation++, jdbcConstraint.getParameter1());
            }

            if (jdbcConstraint.getParameter2() != null) {
                preparedStatement.setObject(parameterLocation++, jdbcConstraint.getParameter2());
            }
        }

        return preparedStatement;
    }
709645
public static void checkedUpdate (PreparedStatement stmt, int expectedCount)
        throws SQLException, PersistenceException
    {
        int modified = stmt.executeUpdate();
        if (modified != expectedCount) {
            String err = "Statement did not modify expected number of rows [stmt=" + stmt +
                ", expected=" + expectedCount + ", modified=" + modified + "]";
            throw new PersistenceException(err);
        }
    }
137466
private PrepareResult executeBatchStandard(int estimatedParameterCount) throws SQLException {
    int totalExecutionNumber = getTotalExecutionNumber();
    SQLException exception = null;
    BulkStatus status = new BulkStatus();

    ComStmtPrepare comStmtPrepare = null;
    FutureTask<AsyncMultiReadResult> futureReadTask = null;

    int requestNumberByBulk;
    int paramCount = estimatedParameterCount;
    try {
      do {
        status.sendEnded = false;
        status.sendSubCmdCounter = 0;
        requestNumberByBulk = Math.min(totalExecutionNumber - status.sendCmdCounter,
            protocol.getOptions().useBatchMultiSendNumber);
        protocol.changeSocketTcpNoDelay(false); //enable NAGLE algorithm temporary.

        //add prepare sub-command
        if (readPrepareStmtResult && prepareResult == null) {

          comStmtPrepare = new ComStmtPrepare(protocol, sql);
          comStmtPrepare.send(writer);

          //read prepare result
          prepareResult = comStmtPrepare.read(protocol.getReader(), protocol.isEofDeprecated());
          statementId = ((ServerPrepareResult) prepareResult).getStatementId();
          paramCount = getParamCount();
        }

        boolean useCurrentThread = false;

        for (; status.sendSubCmdCounter < requestNumberByBulk; ) {
          sendCmd(writer, results, parametersList, queries, paramCount, status, prepareResult);
          status.sendSubCmdCounter++;
          status.sendCmdCounter++;
          if (useCurrentThread) {
            try {
              protocol.getResult(results);
            } catch (SQLException qex) {
              if (((readPrepareStmtResult && prepareResult == null) || !protocol
                  .getOptions().continueBatchOnError)) {
                throw qex;
              } else {
                exception = qex;
              }
            }
          } else if (futureReadTask == null) {
            try {
              futureReadTask = new FutureTask<>(new AsyncMultiRead(comStmtPrepare, status,
                  protocol, false, this, paramCount,
                  results, parametersList, queries, prepareResult));
              AbstractQueryProtocol.readScheduler.execute(futureReadTask);
            } catch (RejectedExecutionException r) {
              useCurrentThread = true;
              try {
                protocol.getResult(results);
              } catch (SQLException qex) {
                if (((readPrepareStmtResult && prepareResult == null) || !protocol
                    .getOptions().continueBatchOnError)) {
                  throw qex;
                } else {
                  exception = qex;
                }
              }
            }
          }
        }

        status.sendEnded = true;
        if (!useCurrentThread) {
          protocol.changeSocketTcpNoDelay(protocol.getOptions().tcpNoDelay);
          try {
            AsyncMultiReadResult asyncMultiReadResult = futureReadTask.get();

            if (binaryProtocol && prepareResult == null
                && asyncMultiReadResult.getPrepareResult() != null) {
              prepareResult = asyncMultiReadResult.getPrepareResult();
              statementId = ((ServerPrepareResult) prepareResult).getStatementId();
              paramCount = prepareResult.getParamCount();
            }

            if (asyncMultiReadResult.getException() != null) {
              if (((readPrepareStmtResult && prepareResult == null) || !protocol
                  .getOptions().continueBatchOnError)) {
                throw asyncMultiReadResult.getException();
              } else {
                exception = asyncMultiReadResult.getException();
              }
            }
          } catch (ExecutionException executionException) {
            if (executionException.getCause() == null) {
              throw new SQLException("Error reading results " + executionException.getMessage());
            }
            throw new SQLException(
                "Error reading results " + executionException.getCause().getMessage());
          } catch (InterruptedException interruptedException) {
            protocol.setActiveFutureTask(futureReadTask);
            Thread.currentThread().interrupt();
            throw new SQLException("Interrupted awaiting response ",
                INTERRUPTED_EXCEPTION.getSqlState(), interruptedException);
          } finally {
            //bulk can prepare, and so if prepare cache is enable, can replace an already cached prepareStatement
            //this permit to release those old prepared statement without conflict.
            protocol.forceReleaseWaitingPrepareStatement();
          }
        }

        if (protocol.isInterrupted()) {
          //interrupted during read, must throw an exception manually
          futureReadTask.cancel(true);
          throw new SQLTimeoutException("Timeout during batch execution");
        }
        futureReadTask = null;

      } while (status.sendCmdCounter < totalExecutionNumber);

      if (exception != null) {
        throw exception;
      }

      return prepareResult;

    } catch (IOException e) {
      status.sendEnded = true;
      status.sendCmdCounter = 0; //to ensure read doesn't hang
      throw protocol.handleIoException(e);
    }

  }
867441
private PreparedStatement prepareQuery(String tableName, Query query) {
        // All queries start with SELECT * FROM <keyspace>.<table>
        StringBuilder cql = new StringBuilder("SELECT * FROM ");
        cql.append(m_keyspace);
        cql.append(".");
        cql.append(tableName);
        
        switch (query) {
        case SELECT_1_ROW_1_COLUMN:
            cql.append(" WHERE key = ? AND column1 = ?;");
            break;
        case SELECT_1_ROW_COLUMN_RANGE:
            cql.append(" WHERE key = ? AND column1 >= ? AND column1 < ? LIMIT ?;");
            break;
        case SELECT_1_ROW_COLUMN_SET:
            cql.append(" WHERE key = ? AND column1 IN ?;");
            break;
        case SELECT_1_ROW_ALL_COLUMNS:
            cql.append(" WHERE key = ? LIMIT ?;");
            break;
        case SELECT_1_ROW_UPPER_COLUMNS:
            cql.append(" WHERE key = ? AND column1 >= ? LIMIT ?;");
            break;
        case SELECT_1_ROW_LOWER_COLUMNS:
            cql.append(" WHERE key = ? AND column1 <= ? LIMIT ?;");
            break;
        case SELECT_ROWS_RANGE:
            //unfortunately I didn't find how to get first column of each row in CQL.
            cql.append(" ;");
            break;
        default: 
            throw new RuntimeException("Not supported: " + query);
        }
        m_logger.debug("Preparing query {}: {}", query, cql);
        return ((CQLService)DBService.instance(m_tenant)).getSession().prepare(cql.toString());
    }
1112673
@Override
	public int[] doBatch(final SqlContext sqlContext, final PreparedStatement preparedStatement, final int[] result) {
		if (LOG.isDebugEnabled()) {
			int[] counts = result;
			try {
				counts = new int[] { preparedStatement.getUpdateCount() };
			} catch (SQLException ex) {
				ex.printStackTrace();
			}

			StringBuilder builder = new StringBuilder();
			for (int val : counts) {
				builder.append(val).append(", ");
			}
			LOG.debug("SQL:{} executed. Result:{}", sqlContext.getSqlName(), builder.toString());
		}
		return result;
	}
290620
@Override
    public void prepare(final AbstractSQLInsertUpdate<?> _insertUpdate,
                        final Attribute _attribute,
                        final Object... _values)
        throws SQLException
    {
        checkSQLColumnSize(_attribute, 2);
        final Rate value = eval(_values);
        _insertUpdate.column(_attribute.getSqlColNames().get(0), value.getNumerator());
        _insertUpdate.column(_attribute.getSqlColNames().get(1), value.getDenominator());
    }