Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.RowCallbackHandler


            PreparedStatementCreator originalCreator = super.getPreparedStatementCreator(sql, paramSource);
            return new StreamingStatementCreator(originalCreator);
          }
         
        };
        template.query(sql_, params, new RowCallbackHandler() {
          int rowNum=0;
          @Override
          public void processRow(ResultSet rs) throws SQLException {
            handler.handleRow(mapper.mapRow(rs, rowNum++));
          }
View Full Code Here


        new Trade("UK21341EAH46", 112, new BigDecimal("18.12"), "customer2"),
        new Trade("UK21341EAH47", 245, new BigDecimal("12.78"), "customer2"),
        new Trade("UK21341EAH48", 108, new BigDecimal("109.25"), "customer3"),
        new Trade("UK21341EAH49", 854, new BigDecimal("123.39"), "customer4"));

        jdbcTemplate.query(GET_TRADES, new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        Trade trade = trades.get(activeRow++);

        assertTrue(trade.getIsin().equals(rs.getString(1)));
        assertTrue(trade.getQuantity() == rs.getLong(2));
        assertTrue(trade.getPrice().equals(rs.getBigDecimal(3)));
        assertTrue(trade.getCustomer().equals(rs.getString(4)));
      }
    });

    assertEquals(activeRow, trades.size());

    activeRow = 0;
        jdbcTemplate.query(GET_CUSTOMERS, new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        Customer customer = customers.get(activeRow++);

        assertEquals(customer.getName(),rs.getString(1));
View Full Code Here

   * only the ordering of these first three columns.
   */
  public void loadBeanDefinitions(String sql) {
    Assert.notNull(this.jdbcTemplate, "Not fully configured - specify DataSource or JdbcTemplate");
    final Properties props = new Properties();
    this.jdbcTemplate.query(sql, new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        String beanName = rs.getString(1);
        String property = rs.getString(2);
        String value = rs.getString(3);
View Full Code Here

    given(resultSet.getString("forename")).willReturn("rod");

    params.put("id", new SqlParameterValue(Types.DECIMAL, 1));
    params.put("country", "UK");
    final List<Customer> customers = new LinkedList<Customer>();
    namedParameterTemplate.query(SELECT_NAMED_PARAMETERS, params, new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        Customer cust = new Customer();
        cust.setId(rs.getInt(COLUMN_NAMES[0]));
        cust.setForename(rs.getString(COLUMN_NAMES[1]));
View Full Code Here

    given(resultSet.next()).willReturn(true, false);
    given(resultSet.getInt("id")).willReturn(1);
    given(resultSet.getString("forename")).willReturn("rod");

    final List<Customer> customers = new LinkedList<Customer>();
    namedParameterTemplate.query(SELECT_NO_PARAMETERS, new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        Customer cust = new Customer();
        cust.setId(rs.getInt(COLUMN_NAMES[0]));
        cust.setForename(rs.getString(COLUMN_NAMES[1]));
View Full Code Here

  private Importer importer;
 
  private Map<String, String> getCountryNames(String countrycode) {
    if (countryNames == null) {
      countryNames = new HashMap<String, Map<String,String>>();
      template.query("SELECT country_code, name FROM country_name;", new RowCallbackHandler() {
        @Override
        public void processRow(ResultSet rs) throws SQLException {
          countryNames.put(rs.getString("country_code"), DBUtils.getMap(rs, "name"));
        }
      }
View Full Code Here

   
    final BlockingQueue<PhotonDoc> documents = new LinkedBlockingDeque<PhotonDoc>(20);
    Thread importThread = new Thread(new ImportThread(documents));
    importThread.start();

    template.query("SELECT " + selectColsPlaceX + " FROM placex WHERE linked_place_id IS NULL order by geometry_sector; ", new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        PhotonDoc doc = placeRowMapper.mapRow(rs, 0);

        if(!doc.isUsefulForIndex()) return; // do not import document
View Full Code Here

   */
  @Override
  public Set<JobExecution> findRunningJobExecutions(String jobName) {

    final Set<JobExecution> result = new HashSet<JobExecution>();
    RowCallbackHandler handler = new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        JobExecutionRowMapper mapper = new JobExecutionRowMapper();
        result.add(mapper.mapRow(rs, 0));
      }
View Full Code Here

   * @param executionId
   * @return
   */
  protected JobParameters getJobParameters(Long executionId) {
    final Map<String, JobParameter> map = new HashMap<String, JobParameter>();
    RowCallbackHandler handler = new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        ParameterType type = ParameterType.valueOf(rs.getString(3));
        JobParameter value = null;

View Full Code Here

  @Test
  public void testSetValues() {

    final List<String> results = new ArrayList<String>();
    jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss,
        new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        results.add(rs.getString(1));
      }
    });
View Full Code Here

TOP

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

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.