Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.SqlParameterValue


    replay();

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("perfId", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("priceId", new SqlParameterValue(Types.INTEGER, new Integer(1)));
    int rowsAffected = jt.update(UPDATE_NAMED_PARAMETERS, params);
    assertEquals(1, rowsAffected);
  }
View Full Code Here


    replay();

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("id", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("country", "UK");
    Customer cust = (Customer) jt.query(SELECT_NAMED_PARAMETERS, params, new ResultSetExtractor() {
      public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
        rs.next();
        Customer cust = new Customer();
View Full Code Here

    replay();

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("id", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("country", "UK");
    final List customers = new LinkedList();
    jt.query(SELECT_NAMED_PARAMETERS, params, new RowCallbackHandler() {
      public void processRow(ResultSet rs) throws SQLException {
        Customer cust = new Customer();
View Full Code Here

    replay();

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("id", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("country", "UK");
    List customers = jt.query(SELECT_NAMED_PARAMETERS, params, new RowMapper() {
      public Object mapRow(ResultSet rs, int rownum) throws SQLException {
        Customer cust = new Customer();
        cust.setId(rs.getInt(COLUMN_NAMES[0]));
View Full Code Here

    replay();

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("id", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("country", "UK");
    Customer cust = (Customer) jt.queryForObject(SELECT_NAMED_PARAMETERS, params, new RowMapper() {
      public Object mapRow(ResultSet rs, int rownum) throws SQLException {
        Customer cust = new Customer();
        cust.setId(rs.getInt(COLUMN_NAMES[0]));
View Full Code Here

      }
    }.runTest();
  }

  public void testSqlParameterValueRegistersSqlType() throws Exception {
    MapSqlParameterSource msps = new MapSqlParameterSource("FOO", new SqlParameterValue(2, "Foo"));
    assertEquals("Correct SQL Type not registered", 2, msps.getSqlType("FOO"));
    MapSqlParameterSource msps2 = new MapSqlParameterSource();
    msps2.addValues(msps.getValues());
    assertEquals("Correct SQL Type not registered", 2, msps2.getSqlType("FOO"));
  }
View Full Code Here

        Object[] args = argsList.get(i);
        if (args != null) {
          for (int index = 0; index < args.length; index++) {
            Object arg = args[index];
            if (arg instanceof SqlParameterValue) {
              SqlParameterValue paramValue = (SqlParameterValue) arg;
              StatementCreatorUtils.setParameterValue(ps, index + 1, paramValue, paramValue.getValue());
            } else {
              StatementCreatorUtils.setParameterValue(ps, index + 1, SqlTypeValue.TYPE_UNKNOWN, arg);
            }
          }
        }
View Full Code Here

        if (args != null) {
          for (int i = 0; i < args.length; i++) {
            Object arg = args[i];
            if (arg instanceof SqlParameterValue) {
              SqlParameterValue paramValue = (SqlParameterValue) arg;
              StatementCreatorUtils.setParameterValue(ps, i + 1, paramValue, paramValue.getValue());
            } else {
              StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, arg);
            }
          }
        }
View Full Code Here

    source.getValue("pechorin was right!");
  }

  @Test
  public void sqlParameterValueRegistersSqlType() throws Exception {
    MapSqlParameterSource msps = new MapSqlParameterSource("FOO", new SqlParameterValue(2, "Foo"));
    assertEquals("Correct SQL Type not registered", 2, msps.getSqlType("FOO"));
    MapSqlParameterSource msps2 = new MapSqlParameterSource();
    msps2.addValues(msps.getValues());
    assertEquals("Correct SQL Type not registered", 2, msps2.getSqlType("FOO"));
  }
View Full Code Here

    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());
      }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.SqlParameterValue

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.