Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.SqlParameter


  @SuppressWarnings("nls")
  @Override
  protected void onCompileInternal(){
    Iterator<SqlParameter> logicalParametersIterator = logicalParameters.iterator();
    List<SqlParameter> callParameters = getCallParameters();
    SqlParameter logicalParameter;
    Object value = null;
    int index = 0;
   
    compiled = true;
   
    for (SqlParameter callParameter : callParameters){
      if (!logicalParametersIterator.hasNext()){
        // Metadata has more parameters than were passed
        throw new BadSqlGrammarException("JDBC Call", this.getCallString(), new SQLException("Not enough parameters provided."));
      }
     
      // The logical name is the name this parameter is known as to a client
      logicalParameter = logicalParametersIterator.next();
     
      // Map the database parameter name to the logical parameter and the logical
      // parameter name to the db name
      dbNameToLogicalParameterMap.put(callParameter.getName(), logicalParameter);
      logicalNameToDbNameMap.put(logicalParameter.getName(), callParameter.getName());
     
      // If this is an IN or IN/OUT parameter, map the database name to
      // the value supplied by the client.  Calls convertInputValue to
      // give subclasses a chance to convert the provided input value.
      if (callParameter.isInputValueProvided()){
View Full Code Here


   * db name.
   *
   * @param dbName the name of the parameter as defined in the db
   */
  protected String getLogicalParameterName(String dbName){
    SqlParameter parameter = dbNameToLogicalParameterMap.get(dbName);
   
    return parameter != null ? parameter.getName() : null;
  }
View Full Code Here

      if (isRefCursorType(meta)){
        throw new UnsupportedOperationException("A ref cursor is not supported as an input parameter.");
      }else if (isPLSQLRecordType(meta)){
        throw new UnsupportedOperationException("A PL/SQL record is not currently supported as an input parameter.");
      }else if (isArrayType(meta)){
        return new SqlParameter(parameterName, getArrayType(), getArgumentType(meta));
      }else if (isFloatType(meta)){
        return new SqlParameter(parameterName, OracleTypes.FLOAT);
      }else{
        return new SqlParameter(parameterName, getStructType(), meta.getTypeName());
      }
    }

    return super.createDefaultInParameter(parameterName, meta);
  }
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

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

    // iterate over the declared RowMappers and register the corresponding SqlParameter
    for (Map.Entry<String, RowMapper> 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

    List<String> paramNames = parsedSql.getParameterNames();
    for (int i = 0; i < paramNames.size(); i++) {
      String paramName = paramNames.get(i);
      try {
        Object value = paramSource.getValue(paramName);
        SqlParameter param = findParameter(declaredParams, paramName, i);
        paramArray[i] = (param != null ? new SqlParameterValue(param, value) : value);
      }
      catch (IllegalArgumentException ex) {
        throw new InvalidDataAccessApiUsageException(
            "No value supplied for the SQL parameter '" + paramName + "': " + ex.getMessage());
View Full Code Here

          return declaredParam;
        }
      }
      // Second pass: Look for parameter index match.
      if (paramIndex < declaredParams.size()) {
        SqlParameter declaredParam = declaredParams.get(paramIndex);
        // Only accept unnamed parameters for index matches.
        if (declaredParam.getName() == null) {
          return declaredParam;
        }
      }
    }
    return null;
View Full Code Here

   */
  public static List<SqlParameter> buildSqlParameterList(ParsedSql parsedSql, SqlParameterSource paramSource) {
    List<String> paramNames = parsedSql.getParameterNames();
    List<SqlParameter> params = new LinkedList<SqlParameter>();
    for (String paramName : paramNames) {
      SqlParameter param = new SqlParameter(
          paramName,
          paramSource.getSqlType(paramName),
          paramSource.getTypeName(paramName));
      params.add(param);
    }
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

    List paramNames = parsedSql.getParameterNames();
    for (int i = 0; i < paramNames.size(); i++) {
      String paramName = (String) paramNames.get(i);
      try {
        Object value = paramSource.getValue(paramName);
        SqlParameter param = findParameter(declaredParams, paramName, i);
        paramArray[i] = (param != null ? new SqlParameterValue(param, value) : value);
      }
      catch (IllegalArgumentException ex) {
        throw new InvalidDataAccessApiUsageException(
            "No value supplied for the SQL parameter '" + paramName + "': " + ex.getMessage());
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.