Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.SqlParameter


   */
  private static SqlParameter findParameter(List declaredParams, String paramName, int paramIndex) {
    if (declaredParams != null) {
      // First pass: Look for named parameter match.
      for (Iterator it = declaredParams.iterator(); it.hasNext();) {
        SqlParameter declaredParam = (SqlParameter) it.next();
        if (paramName.equals(declaredParam.getName())) {
          return declaredParam;
        }
      }
      // Second pass: Look for parameter index match.
      if (paramIndex < declaredParams.size()) {
        SqlParameter declaredParam = (SqlParameter) declaredParams.get(paramIndex);
        // Only accept unnamed parameters for index matches.
        if (declaredParam.getName() == null) {
          return declaredParam;
        }
      }
    }
    return null;
View Full Code Here


        parNameToCheck = this.metaDataProvider.parameterNameToUse(meta.getParameterName()).toLowerCase();
      }
      String parNameToUse = this.metaDataProvider.parameterNameToUse(meta.getParameterName());
      if (declaredParameters.containsKey(parNameToCheck) ||
          (meta.getParameterType() == DatabaseMetaData.procedureColumnReturn && returnDeclared)) {
        SqlParameter parameter;
        if (meta.getParameterType() == DatabaseMetaData.procedureColumnReturn) {
          parameter = declaredParameters.get(this.getFunctionReturnName());
          if (parameter == null && this.getOutParameterNames().size() > 0) {
            parameter = declaredParameters.get(this.getOutParameterNames().get(0).toLowerCase());
          }
          if (parameter == null) {
            throw new InvalidDataAccessApiUsageException(
                "Unable to locate declared parameter for function return value - " +
                    " add an SqlOutParameter with name \"" + getFunctionReturnName() +"\"");
          }
          else {
            this.setFunctionReturnName(parameter.getName());
          }
        }
        else {
          parameter = declaredParameters.get(parNameToCheck);
        }
View Full Code Here

  protected void compileInternal() {
    this.callMetaDataContext.initializeMetaData(getJdbcTemplate().getDataSource());

    // iterate over the declared RowMappers and register the corresponding SqlParameter
    for (Map.Entry<String, ParameterizedRowMapper> entry : this.declaredRowMappers.entrySet()) {
      SqlParameter resultSetParameter =
          this.callMetaDataContext.createReturnResultSetParameter(entry.getKey(), entry.getValue());
      this.declaredParameters.add(resultSetParameter);
    }
    callMetaDataContext.processParameters(this.declaredParameters);
View Full Code Here

  public SqlParameter createDefaultInOutParameter(String parameterName, CallParameterMetaData meta) {
    return new SqlInOutParameter(parameterName, meta.getSqlType());
  }

  public SqlParameter createDefaultInParameter(String parameterName, CallParameterMetaData meta) {
    return new SqlParameter(parameterName, meta.getSqlType());   
  }
View Full Code Here

      }
      else {
        this.callString = "{call " + getSql() + "(";
      }
      for (int i = 0; i < parameters.size(); i++) {
        SqlParameter parameter = (SqlParameter) parameters.get(i);
        if (!(parameter.isResultsParameter())) {
          if (parameterCount > 0) {
            this.callString += ", ";
          }
          if (parameterCount >= 0) {
            this.callString += "?";
View Full Code Here

    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException("Cannot add parameters once query is compiled");
    }
    if (types != null) {
      for (int i = 0; i < types.length; i++) {
        declareParameter(new SqlParameter(types[i]));
      }
    }
  }
View Full Code Here

    checkCompiled();

    int declaredInParameters = 0;
    Iterator it = this.declaredParameters.iterator();
    while (it.hasNext()) {
      SqlParameter param = (SqlParameter) it.next();
      if (param.isInputValueProvided()) {
        if (!supportsLobParameters() &&
            (param.getSqlType() == Types.BLOB || param.getSqlType() == Types.CLOB)) {
          throw new InvalidDataAccessApiUsageException(
              "BLOB or CLOB parameters are not allowed for this kind of operation");
        }
        declaredInParameters++;
      }
View Full Code Here

    Map paramsToUse = (parameters != null ? parameters : Collections.EMPTY_MAP);

    int declaredInParameters = 0;
    Iterator it = this.declaredParameters.iterator();
    while (it.hasNext()) {
      SqlParameter param = (SqlParameter) it.next();
      if (param.isInputValueProvided()) {
        if (!supportsLobParameters() &&
            (param.getSqlType() == Types.BLOB || param.getSqlType() == Types.CLOB)) {
          throw new InvalidDataAccessApiUsageException(
              "BLOB or CLOB parameters are not allowed for this kind of operation");
        }
        if (param.getName() != null && !paramsToUse.containsKey(param.getName())) {
          throw new InvalidDataAccessApiUsageException("The parameter named '" + param.getName() +
              "' was not among the parameters supplied: " + paramsToUse.keySet());
        }
        declaredInParameters++;
      }
    }
View Full Code Here

    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException("Cannot add parameters once query is compiled");
    }
    if (types != null) {
      for (int i = 0; i < types.length; i++) {
        declareParameter(new SqlParameter(types[i]));
      }
    }
  }
View Full Code Here

    checkCompiled();

    int declaredInParameters = 0;
    Iterator it = this.declaredParameters.iterator();
    while (it.hasNext()) {
      SqlParameter param = (SqlParameter) it.next();
      if (param.isInputValueProvided()) {
        if (!supportsLobParameters() &&
            (param.getSqlType() == Types.BLOB || param.getSqlType() == Types.CLOB)) {
          throw new InvalidDataAccessApiUsageException(
              "BLOB or CLOB parameters are not allowed for this kind of operation");
        }
        declaredInParameters++;
      }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.SqlParameter

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.