Package com.skyline.energy.exception

Examples of com.skyline.energy.exception.DataAccessException


  public Number getKey() {
    if (this.keyList.size() == 0) {
      return null;
    }
    if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) {
      throw new DataAccessException("The getKey method should only be used when a single key is returned.  "
          + "The current key entry contains multiple keys: " + this.keyList);
    }
    Iterator<Object> keyIter = this.keyList.get(0).values().iterator();
    if (keyIter.hasNext()) {
      Object key = keyIter.next();
      if (!(key instanceof Number)) {
        throw new DataAccessException("The generated key is not of a supported numeric type. "
            + "Unable to cast [" + (key != null ? key.getClass().getName() : null) + "] to ["
            + Number.class.getName() + "]");
      }
      return (Number) key;
    } else {
      throw new DataAccessException("Unable to retrieve the generated key. "
          + "Check that the table has an identity column enabled.");
    }
  }
View Full Code Here


  public Map<String, Object> getKeys() {
    if (this.keyList.size() == 0) {
      return null;
    }
    if (this.keyList.size() > 1)
      throw new DataAccessException(
          "The getKeys method should only be used when keys for a single row are returned.  "
              + "The current key list contains keys for multiple rows: " + this.keyList);
    return this.keyList.get(0);
  }
View Full Code Here

  public Integer mapRow(ResultSet rs, int rowNum) throws SQLException {
    // Validate column count.
    ResultSetMetaData rsmd = rs.getMetaData();
    int nrOfColumns = rsmd.getColumnCount();
    if (nrOfColumns != 1) {
      throw new DataAccessException("Incorrect column count: expected 1, actual " + nrOfColumns);
    }
    return rs.getInt(1);
  }
View Full Code Here

    } catch (SQLException ex) {
      JdbcUtils.closeStatement(ps);
      ps = null;
      JdbcUtils.releaseConnection(con);
      con = null;
      throw new DataAccessException(ex);
    } finally {
      JdbcUtils.closeStatement(ps);
      JdbcUtils.releaseConnection(con);
    }
  }
View Full Code Here

        return doGetConnection(((DistributeDataSource) dataSource).getDataSource(), true);
      } else {
        return doGetConnection(dataSource, false);
      }
    } catch (SQLException ex) {
      throw new DataAccessException("Could not get JDBC Connection", ex);
    }
  }
View Full Code Here

        if (!(key instanceof Number)) {
          String className = null;
          if (key != null) {
            className = key.getClass().getName();
          }
          throw new DataAccessException("The generated key is not of a supported numeric type. "
              + "Unable to cast [" + className + "] to [" + Number.class.getName() + "]");
        }
        keys.add((Number) key);
      }
    }
View Full Code Here

    }
    if (short.class.equals(componentType)) {
      Short[] array = keys.toArray(new Short[length]);
      return ArrayUtils.toPrimitive(array);
    }
    throw new DataAccessException("can't parse return type of [" + componentType);
  }
View Full Code Here

TOP

Related Classes of com.skyline.energy.exception.DataAccessException

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.