Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.JdbcTemplate.update()


  @Before
  public void init() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
    for (int i = maxId + 1; i <= ITEM_COUNT; i++) {
      jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
    }
    assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
  }

  @After
View Full Code Here


  }

  @After
  public void destroy() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
  }

  @Test
  public void testAsyncReader() throws Throwable {
    List<Throwable> throwables = new ArrayList<Throwable>();
View Full Code Here

  @Before
  public void init() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
    for (int i = ITEM_COUNT; i > maxId; i--) {
      jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
    }
    assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
  }

  @After
View Full Code Here

  }

  @After
  public void destroy() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
  }

  @Test
  public void testAsyncReader() throws Throwable {
    List<Throwable> throwables = new ArrayList<Throwable>();
View Full Code Here

  @Before
  public void init() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
    for (int i = maxId + 1; i <= ITEM_COUNT; i++) {
      jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
    }
    assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
  }

  @After
View Full Code Here

  }

  @After
  public void destroy() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
  }

  @Test
  public void testAsyncReader() throws Throwable {
    List<Throwable> throwables = new ArrayList<Throwable>();
View Full Code Here

  @Before
  public void init() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
    for (int i = maxId + 1; i <= ITEM_COUNT; i++) {
      jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
    }
    assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
  }

  @After
View Full Code Here

  }

  @After
  public void destroy() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
  }

  @Test
  public void testAsyncReader() throws Throwable {
    List<Throwable> throwables = new ArrayList<Throwable>();
View Full Code Here

    @Transactional
    public void completeTask(String taskId) {

        // First insert a record in the MY_TABLE table
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        int nrOfRows = jdbcTemplate.update("insert into MY_TABLE values ('test');");
        if (nrOfRows != 1) {
            throw new RuntimeException("Insert into MY_TABLE failed");
        }

        taskService.complete(taskId);
View Full Code Here

    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "INSERT INTO resource_metadata (name,dimension_id,db_type,is_partitioning_resource) VALUES (?,?,?,?)",
        new int[] {Types.VARCHAR,Types.INTEGER,Types.VARCHAR,Types.BIT});
    creatorFactory.setReturnGeneratedKeys(true);
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to create Resource: "
          + parameters);
    if (generatedKey.getKeyList().size() == 0)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.