Package org.springframework.dao

Examples of org.springframework.dao.InvalidDataAccessApiUsageException


   * @throws InvalidDataAccessApiUsageException if the operation is already compiled,
   * and hence cannot be configured further
   */
  public void declareParameter(SqlParameter param) throws InvalidDataAccessApiUsageException {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException("Cannot add parameters once the query is compiled");
    }
    this.declaredParameters.add(param);
  }
View Full Code Here


   * @param parameters Array containing the declared {@link SqlParameter} objects
   * @see #declaredParameters
   */
  public void setParameters(SqlParameter[] parameters) {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException("Cannot add parameters once the query is compiled");
    }
    for (int i = 0; i < parameters.length; i++) {
      if (parameters[i] != null) {
        this.declaredParameters.add(parameters[i]);
      }
      else {
        throw new InvalidDataAccessApiUsageException("Cannot add parameter at index " + i + " from " +
            Arrays.asList(parameters) + " since it is 'null'");
      }
    }
  }
View Full Code Here

   * been correctly initialized, for example if no DataSource has been provided
   */
  public final void compile() throws InvalidDataAccessApiUsageException {
    if (!isCompiled()) {
      if (getSql() == null) {
        throw new InvalidDataAccessApiUsageException("Property 'sql' is required");
      }

      try {
        this.jdbcTemplate.afterPropertiesSet();
      }
      catch (IllegalArgumentException ex) {
        throw new InvalidDataAccessApiUsageException(ex.getMessage());
     
   
      compileInternal();
      this.compiled = true;

View Full Code Here

    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

    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

   * @param suppliedParamCount the number of actual parameters given
   * @param declaredInParamCount the number of input parameters declared
   */
  private void validateParameterCount(int suppliedParamCount, int declaredInParamCount) {
    if (suppliedParamCount < declaredInParamCount) {
      throw new InvalidDataAccessApiUsageException(suppliedParamCount + " parameters were supplied, but " +
          declaredInParamCount + " in parameters were declared in class [" + getClass().getName() + "]");
    }
    if (suppliedParamCount > this.declaredParameters.size() && !allowsUnusedParameters()) {
      throw new InvalidDataAccessApiUsageException(suppliedParamCount + " parameters were supplied, but " +
          declaredInParamCount + " parameters were declared in class [" + getClass().getName() + "]");
    }
  }
View Full Code Here

   * Names are purely used to help mapping.
   * @param param parameter object
   */
  public void declareParameter(SqlParameter param) throws InvalidDataAccessApiUsageException {
    if (param.getName() == null) {
      throw new InvalidDataAccessApiUsageException("Parameters to stored procedures must have names as well as types");
    }
    super.declareParameter(param);
  }
View Full Code Here

    else if (ex instanceof SQLNonTransientException) {
      if (ex instanceof SQLDataException) {
        return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLFeatureNotSupportedException) {
        return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLIntegrityConstraintViolationException) {
        return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLInvalidAuthorizationSpecException) {
View Full Code Here

            this.clobClass, new Integer(this.clobClass.getField(DURATION_SESSION_FIELD_NAME).getInt(null)));
        this.modeReadWriteConstants.put(
            this.clobClass, new Integer(this.clobClass.getField(MODE_READWRITE_FIELD_NAME).getInt(null)));
      }
      catch (Exception ex) {
        throw new InvalidDataAccessApiUsageException(
            "Couldn't initialize OracleLobHandler because Oracle driver classes are not available. " +
            "Note that OracleLobHandler requires Oracle JDBC driver 9i or higher!", ex);
      }
    }
  }
View Full Code Here

      catch (InvocationTargetException ex) {
        if (ex.getTargetException() instanceof SQLException) {
          throw (SQLException) ex.getTargetException();
        }
        else if (con != null && ex.getTargetException() instanceof ClassCastException) {
          throw new InvalidDataAccessApiUsageException(
              "OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], not on [" +
              con.getClass().getName() + "]: specify a corresponding NativeJdbcExtractor",
              ex.getTargetException());
        }
        else {
View Full Code Here

TOP

Related Classes of org.springframework.dao.InvalidDataAccessApiUsageException

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.