Package org.springframework.dao

Examples of org.springframework.dao.InvalidDataAccessApiUsageException


   * @param parameter the {@link SqlParameter} to add
   */
  public void addDeclaredParameter(SqlParameter parameter) {
    Assert.notNull(parameter, "The supplied parameter must not be null");
    if (!StringUtils.hasText(parameter.getName())) {
      throw new InvalidDataAccessApiUsageException(
          "You must specify a parameter name when declaring parameters for \"" + getProcedureName() + "\"");
    }
    this.declaredParameters.add(parameter);
    if (logger.isDebugEnabled()) {
      logger.debug("Added declared parameter for [" + getProcedureName() + "]: " + parameter.getName());
View Full Code Here


   * been correctly initialized, for example if no DataSource has been provided
   */
  public synchronized final void compile() throws InvalidDataAccessApiUsageException {
    if (!isCompiled()) {
      if (getProcedureName() == null) {
        throw new InvalidDataAccessApiUsageException("Procedure or Function name is required");
      }
      try {
        this.jdbcTemplate.afterPropertiesSet();
      }
      catch (IllegalArgumentException ex) {
        throw new InvalidDataAccessApiUsageException(ex.getMessage());
      }
      compileInternal();
      this.compiled = true;
      if (logger.isDebugEnabled()) {
        logger.debug("SqlCall for " + (isFunction() ? "function" : "procedure") + " [" + getProcedureName() + "] compiled");
View Full Code Here

      setIncludeSynonyms = con.getClass().getMethod("setIncludeSynonyms", new Class[] {boolean.class});
      ReflectionUtils.makeAccessible(setIncludeSynonyms);
      setIncludeSynonyms.invoke(con, Boolean.TRUE);
    }
    catch (Exception ex) {
      throw new InvalidDataAccessApiUsageException("Couldn't prepare Oracle Connection", ex);
    }

    super.initializeWithTableColumnMetaData(databaseMetaData, catalogName, schemaName, tableName);

    try {
      setIncludeSynonyms.invoke(con, originalValueForIncludeSynonyms);
    }
    catch (Exception ex) {
      throw new InvalidDataAccessApiUsageException("Couldn't reset Oracle Connection", ex);
    }
  }
View Full Code Here

        if (j < statement.length && c == ':' && statement[j] == '{') {
          // :{x} style parameter
          while (j < statement.length && !('}' == statement[j])) {
            j++;
            if (':' == statement[j] || '{' == statement[j]) {
              throw new InvalidDataAccessApiUsageException("Parameter name contains invalid character '" + statement[j] + "' at position " + i + " in statement " + sql);
            }
          }
          if (j >= statement.length) {
            throw new InvalidDataAccessApiUsageException("Non-terminated named parameter declaration at position " + i + " in statement " + sql);
          }
          if (j - i > 3) {
            parameter = sql.substring(i + 2, j);
            namedParameterCount = addNewNamedParameter(namedParameters, namedParameterCount, parameter);
            totalParameterCount = addNamedParameter(parameterList, totalParameterCount, escapes, i, j + 1, parameter);
View Full Code Here

  public static Object[] buildValueArray(
      ParsedSql parsedSql, SqlParameterSource paramSource, List<SqlParameter> declaredParams) {

    Object[] paramArray = new Object[parsedSql.getTotalParameterCount()];
    if (parsedSql.getNamedParameterCount() > 0 && parsedSql.getUnnamedParameterCount() > 0) {
      throw new InvalidDataAccessApiUsageException(
          "You can't mix named and traditional ? placeholders. You have " +
          parsedSql.getNamedParameterCount() + " named parameter(s) and " +
          parsedSql.getUnnamedParameterCount() + " traditonal placeholder(s) in [" +
          parsedSql.getOriginalSql() + "]");
    }
    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());
      }
    }
    return paramArray;
  }
View Full Code Here

        found.add(procs.getString("PROCEDURE_CAT") + "." + procs.getString("PROCEDURE_SCHEM") +
            "." + procs.getString("PROCEDURE_NAME"));
      }
      procs.close();
      if (found.size() > 1) {
        throw new InvalidDataAccessApiUsageException("Unable to determine the correct call signature - " +
            "multiple procedures/functions/signatures for " + metaDataProcedureName + " found " + found);
      }
      if (found.size() < 1) {
        if (metaDataProcedureName.contains(".") && !StringUtils.hasText(metaDataCatalogName)) {
          String packageName = metaDataProcedureName.substring(0, metaDataProcedureName.indexOf("."));
          throw new InvalidDataAccessApiUsageException("Unable to determine the correct call signature for " +
              metaDataProcedureName + " - package name should be specified separately using " +
              "'.withCatalogName(\"" + packageName + "\")'");
        }
      }
View Full Code Here

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

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

      compileInternal();
      this.compiled = true;

View Full Code Here

   * Method to check whether we are allowd to make any configuration changes at this time.  If the class has been
   * compiled, then no further changes to the configuration are allowed.
   */
  protected void checkIfConfigurationModificationIsAllowed() {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException("Configuration can't be altered once the class has been compiled or used.");
    }
  }
View Full Code Here

      if (!this.tableMetaDataContext.isGetGeneratedKeysSimulated()) {
        throw new InvalidDataAccessResourceUsageException(
            "The getGeneratedKeys feature is not supported by this database");
      }
      if (getGeneratedKeyNames().length < 1) {
        throw new InvalidDataAccessApiUsageException("Generated Key Name(s) not specificed. " +
            "Using the generated keys features requires specifying the name(s) of the generated column(s)");
      }
      if (getGeneratedKeyNames().length > 1) {
        throw new InvalidDataAccessApiUsageException(
            "Current database only supports retreiving the key for a single column. There are " +
            getGeneratedKeyNames().length  + " columns specified: " + Arrays.asList(getGeneratedKeyNames()));
      }
      // This is a hack to be able to get the generated key from a database that doesn't support
      // get generated keys feature.  HSQL is one, PostgreSQL is another.  Postgres uses a RETURNING
View Full Code Here

   * @return PreparedStatement to use
   * @throws SQLException
   */
  private PreparedStatement prepareStatementForGeneratedKeys(Connection con) throws SQLException {
    if (getGeneratedKeyNames().length < 1) {
      throw new InvalidDataAccessApiUsageException("Generated Key Name(s) not specificed. " +
          "Using the generated keys features requires specifying the name(s) of the generated column(s)");
    }
    PreparedStatement ps;
    if (this.tableMetaDataContext.isGeneratedKeysColumnNameArraySupported()) {
      if (logger.isDebugEnabled()) {
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.