Package org.springframework.jdbc.core.namedparam

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource


   * @param ftpSetting
   */
  public void insertFtpSetting(FtpSetting ftpSetting) {
    String sql = "insert into sys_ftp(ftp_ip,ftp_port,username,password,ftp_path,ftp_push_rate,enable)"
        + " values(:ftpIp,:ftpPort,:username,:password,:ftpPath,:ftpPushRate,:enable)";
    SqlParameterSource paramMap = new BeanPropertySqlParameterSource(ftpSetting);
    namedParameterJdbcTemplate.update(sql, paramMap);
  }
View Full Code Here


   * @param ftpSetting
   */
  public void updateFtpSetting(FtpSetting ftpSetting) {
    String sql = "update sys_ftp set ftp_ip=:ftpIp,ftp_port=:ftpPort,username=:username,password=:password,"
        + "ftp_path=:ftpPath,ftp_push_rate=:ftpPushRate,enable=:enable";
    SqlParameterSource paramMap = new BeanPropertySqlParameterSource(ftpSetting);
    namedParameterJdbcTemplate.update(sql, paramMap);
  }
View Full Code Here

    int arg1 = 24;
    String arg2 = "foo";

    MockControl mc = MockControl.createControl(NamedParameterJdbcOperations.class);
    NamedParameterJdbcOperations npjo = (NamedParameterJdbcOperations) mc.getMock();
    SqlParameterSource args = new MapSqlParameterSource().addValue("id", arg1).addValue("xy", arg2);
    npjo.queryForInt(sql, args);
    mc.setDefaultMatcher(new ArrayMatcher());
    mc.setReturnValue(expectedResult);
    mc.replay();
View Full Code Here

  @Override
  public void write(List<? extends Game> games) {

    for (Game game : games) {

      SqlParameterSource values = new MapSqlParameterSource().addValue("player_id", game.getId()).addValue(
          "year_no", game.getYear()).addValue("team", game.getTeam()).addValue("week", game.getWeek())
          .addValue("opponent", game.getOpponent()).addValue("completes", game.getCompletes()).addValue(
              "attempts", game.getAttempts()).addValue("passing_yards", game.getPassingYards()).addValue(
              "passing_td", game.getPassingTd()).addValue("interceptions", game.getInterceptions())
          .addValue("rushes", game.getRushes()).addValue("rush_yards", game.getRushYards()).addValue(
View Full Code Here

  @Override
  public void write(List<? extends Game> games) {

    for (Game game : games) {

      SqlParameterSource values = new MapSqlParameterSource().addValue("player_id", game.getId()).addValue(
          "year_no", game.getYear()).addValue("team", game.getTeam()).addValue("week", game.getWeek())
          .addValue("opponent", game.getOpponent()).addValue("completes", game.getCompletes()).addValue(
              "attempts", game.getAttempts()).addValue("passing_yards", game.getPassingYards()).addValue(
              "passing_td", game.getPassingTd()).addValue("interceptions", game.getInterceptions())
          .addValue("rushes", game.getRushes()).addValue("rush_yards", game.getRushYards()).addValue(
View Full Code Here

        //Note: Remember that spring doesn't generate ID. The database generates the next id. Make sure the database
        // has a trigger or autoincrement facility on the ID column.
        SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(getDataSource()).withTableName(TABLE_NAME)
                .usingGeneratedKeyColumns("ID");

        SqlParameterSource parameters = new BeanPropertySqlParameterSource(episode);

        Number id = simpleJdbcInsert.executeAndReturnKey(parameters);
        episode.setId(id.intValue());
        return episode;
    }
View Full Code Here

        //Note: Remember that spring doesn't generate ID. The database generates the next id. Make sure the database
        // has a trigger or autoincrement facility on the ID column.
        SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(getDataSource()).withTableName(TABLE_NAME)
                .usingGeneratedKeyColumns("ID");

        SqlParameterSource parameters = new BeanPropertySqlParameterSource(resource);

        Number id = simpleJdbcInsert.executeAndReturnKey(parameters);
        resource.setId(id.intValue());
        return resource;
    }
View Full Code Here

        final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper();

        // entityType should be center if it's within a center
        final CalendarEntityType entityType = (group.isChildGroup()) ? CalendarEntityType.CENTERS : CalendarEntityType.GROUPS;

        final SqlParameterSource namedParameters = new MapSqlParameterSource().addValue("dueDate", transactionDateStr)
                .addValue("groupId", group.getId()).addValue("officeHierarchy", officeHierarchy)
                .addValue("entityTypeId", entityType.getValue());

        final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(
                mapper.collectionSheetSchema(false), namedParameters, mapper);
View Full Code Here

        final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper();

        StringBuilder sql = new StringBuilder(mapper.collectionSheetSchema(true));

        final SqlParameterSource namedParameters = new MapSqlParameterSource().addValue("dueDate", dueDateStr)
                .addValue("centerId", center.getId()).addValue("officeHierarchy", officeHierarchy)
                .addValue("entityTypeId", CalendarEntityType.CENTERS.getValue());

        final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(sql.toString(),
                namedParameters, mapper);
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.namedparam.SqlParameterSource

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.