Package org.springframework.jdbc.core

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


    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.execute("create table MY_TABLE (MY_TEXT varchar);");
   
    // The hello() method will start the process. The process will wait in a user task
    userBean.hello();
    assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE"));
   
    // The completeTask() method will write a record to the 'MY_TABLE' table and complete the user task
    try {
      userBean.completeTask(taskService.createTaskQuery().singleResult().getId());
      fail();
View Full Code Here


    } catch (Exception e) { }
   
    // Since the service task after the user tasks throws an exception, both
    // the record and the process must be rolled back !
    assertEquals("My Task", taskService.createTaskQuery().singleResult().getName());
    assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE"));
   
    // Cleanup
    jdbcTemplate.execute("drop table MY_TABLE if exists;");
  }
 
View Full Code Here

        // Create new test table
        jt.execute("CREATE TABLE juConnUtilTestTable (id NUMERIC(19))");
        jt.execute("insert into juConnUtilTestTable (id) values (1)");
       
        // Query the table
        Long id = jt.queryForLong("select id from juConnUtilTestTable where id=1");
        Assert.assertEquals(new Long(1), id);
       
        // Create a new connUtil to make sure we'll see the changes there...
        JuConnUtil connUtil2 = JuConnUtils.build()
          .profile(JuUtils.getJuPropertyChain().get("ju-dbutil-test.profile", true))
View Full Code Here

        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        jdbcTemplate.execute("create table MY_TABLE (MY_TEXT varchar);");

        // The hello() method will start the process. The process will wait in a user task
        userBean.hello();
        assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE"));

        // The completeTask() method will write a record to the 'MY_TABLE' table and complete the user task
        try {
            userBean.completeTask(taskService.createTaskQuery().singleResult().getId());
            fail();
View Full Code Here

        }

        // Since the service task after the user tasks throws an exception, both
        // the record and the process must be rolled back !
        assertEquals("My Task", taskService.createTaskQuery().singleResult().getName());
        assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE"));

        // Cleanup
        jdbcTemplate.execute("drop table MY_TABLE if exists;");
    }

View Full Code Here

   * @param nextVal Value that should be yielded by next NEXVAL call
   */
  public void oracleSequenceSetNextVal(String sequenceName, long nextVal) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
   
    Long currentValue = jdbcTemplate.queryForLong(String.format("SELECT %s.NEXTVAL from dual", sequenceName));
    Long increment = nextVal - currentValue - 1;
    jdbcTemplate.execute(String.format("ALTER SEQUENCE %s INCREMENT BY %d", sequenceName, increment));
    jdbcTemplate.execute(String.format("SELECT %s.NEXTVAL from dual", sequenceName));
    jdbcTemplate.execute(String.format("ALTER SEQUENCE %s INCREMENT BY 1", sequenceName));
  }
View Full Code Here

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate.execute("create table MY_TABLE (MY_TEXT varchar);");
   
    // The hello() method will start the process. The process will wait in a user task
    userBean.hello();
    assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE"));
   
    // The completeTask() method will write a record to the 'MY_TABLE' table and complete the user task
    try {
      userBean.completeTask(taskService.createTaskQuery().singleResult().getId());
      fail();
View Full Code Here

    } catch (Exception e) { }
   
    // Since the service task after the user tasks throws an exception, both
    // the record and the process must be rolled back !
    assertEquals("My Task", taskService.createTaskQuery().singleResult().getName());
    assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE"));
   
    // Cleanup
    jdbcTemplate.execute("drop table MY_TABLE if exists;");
  }
 
View Full Code Here

  @FlywayTest(invokeCleanDB=true,locationsForMigrate={"db/test"})
  public void testOne()
  {
    System.out.println("ServiceTest.testOne()");
    JdbcTemplate template  = new JdbcTemplate(ds);
    long count = template.queryForLong("SELECT count(*) from demo5.user_accounts");
    Assert.assertEquals(1, count);
  }
 
  @Test
  @FlywayTest(invokeCleanDB=true,locationsForMigrate={"db/test"})
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.