Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.SqlParameter


  }
 
  class Delete extends SqlUpdate {
    public Delete(DataSource dataSource) {
      super(dataSource, DELETE_SQL);
      declareParameter(new SqlParameter(Types.INTEGER))// TestId
    }
View Full Code Here


  }

  class Insert extends SqlUpdate {
    public Insert(DataSource dataSource) {
      super(dataSource, INSERT_SQL);
      declareParameter(new SqlParameter(Types.VARCHAR))// Name
    }
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

   */
  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

    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

   */
  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

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

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

      if (meta.getParameterName() != null)
        parNameToCheck = metaDataProvider.parameterNameToUse(meta.getParameterName()).toLowerCase();
      String parNameToUse = 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 \"" + this.getFunctionReturnName() +"\"");
          }
          else {
            this.setFunctionReturnName(parameter.getName());
          }
        }
        else {
          parameter = declaredParameters.get(parNameToCheck);
        }
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

  @Override
  public Object convertOutputValue(SqlParameter sqlParameter, Object value){
    CallMetaDataProvider metaDataProvider = callMetaDataContext.getMetaDataProvider();
   
    if (metaDataProvider instanceof VendorTypeHandler){
      SqlParameter logicalParameter = getLogicalParameterByDbName(sqlParameter.getName());
   
      if (logicalParameter instanceof TypedSqlOutParameter){
        return ((VendorTypeHandler)callMetaDataContext.getMetaDataProvider()).transformOutputValue(getJdbcTemplate(), sqlParameter, value, ((TypedSqlOutParameter)logicalParameter).getType());
      }
    }
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.