Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.SqlParameter


    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


      }
      else {
        this.callString = "{call " + getSql() + "(";
      }
      for (int i = 0; i < parameters.size(); i++) {
        SqlParameter parameter = (SqlParameter) parameters.get(i);
        if (!(parameter instanceof SqlReturnResultSet)) {
          if (parameterCount > 0) {
            this.callString += ", ";
          }
          if (parameterCount >= 0) {
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 static final String SQL = "add_invoice";

    public AddInvoice(DataSource ds) {
      setDataSource(ds);
      setSql(SQL);
      declareParameter(new SqlParameter("amount", Types.INTEGER));
      declareParameter(new SqlParameter("custid", Types.INTEGER));
      declareParameter(new SqlOutParameter("newid", Types.INTEGER));
      compile();
    }
View Full Code Here

    public static final String SQL = "takes_null";

    public NullArg(DataSource ds) {
      setDataSource(ds);
      setSql(SQL);
      declareParameter(new SqlParameter("ptest", Types.VARCHAR));
      compile();
    }
View Full Code Here

  private static class UnnamedParameterStoredProcedure extends StoredProcedure {

    public UnnamedParameterStoredProcedure(DataSource ds) {
      super(ds, "unnamed_parameter_sp");
      declareParameter(new SqlParameter(Types.INTEGER));
      compile();
    }
View Full Code Here

  private static class MissingParameterStoredProcedure extends StoredProcedure {

    public MissingParameterStoredProcedure(DataSource ds) {
      setDataSource(ds);
      setSql("takes_string");
      declareParameter(new SqlParameter("mystring", Types.VARCHAR));
      compile();
    }
View Full Code Here

    public static final String SQL = "parameter_mapper_sp";

    public ParameterMapperStoredProcedure(DataSource ds) {
      setDataSource(ds);
      setSql(SQL);
      declareParameter(new SqlParameter("in", Types.VARCHAR));
      declareParameter(new SqlOutParameter("out", Types.VARCHAR));
      compile();
    }
View Full Code Here

    public static final String SQL = "sql_type_value_sp";

    public SqlTypeValueStoredProcedure(DataSource ds) {
      setDataSource(ds);
      setSql(SQL);
      declareParameter(new SqlParameter("in", Types.ARRAY, "NUMBERS"));
      declareParameter(new SqlOutParameter("out", Types.VARCHAR));
      compile();
    }
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.