Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.JdbcOperations.queryForObject()


    assertEquals(new Integer(2),
        template.queryForObject("SELECT COUNT(*) from BAR", Integer.class));
    assertEquals("bar",
        template.queryForObject("SELECT name from BAR WHERE id=1", String.class));
    assertEquals("ばー",
        template.queryForObject("SELECT name from BAR WHERE id=2", String.class));
  }

  @Test
  public void testInitializationDisabled() throws Exception {
    this.context.register(DataSourceAutoConfiguration.class,
View Full Code Here


    assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
    assertNotNull(dataSource);
    JdbcOperations template = new JdbcTemplate(dataSource);

    try {
      template.queryForObject("SELECT COUNT(*) from BAR", Integer.class);
      fail("Query should have failed as BAR table does not exist");
    }
    catch (BadSqlGrammarException ex) {
      SQLException sqlException = ex.getSQLException();
      int expectedCode = -5501; // user lacks privilege or object not found
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.