Package org.springframework.jdbc.core.simple

Examples of org.springframework.jdbc.core.simple.SimpleJdbcTemplate


    {
        Connection connection = dataSource.getConnection();
        strategy.enableVersioning(DatabaseType.H2, connection);
        connection.close();

        SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
        jdbcTemplate.queryForInt("select count(*)" + VERSION_COLUMN + " from " + TABLE_NAME); // Throws exception is table doesn't exist.
    }
View Full Code Here


        Connection connection = dataSource.getConnection();
        strategy.enableVersioning(DatabaseType.H2, connection);
        strategy.recordMigration(DatabaseType.H2, connection, v1, new Date(), 768);
        connection.close();

        SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
        assertThat(jdbcTemplate.queryForInt("select count(*) from " + TABLE_NAME), is(1));
        assertThat(jdbcTemplate.queryForObject("select " + VERSION_COLUMN + " from " + TABLE_NAME, String.class), is(v1));

        connection = dataSource.getConnection();
        strategy.recordMigration(DatabaseType.H2, connection, v2, new Date(), 231);
        connection.close();

        assertThat(jdbcTemplate.queryForInt("select count(*) from " + TABLE_NAME), is(2));

        connection = dataSource.getConnection();
        Set<String> appliedMigrations = strategy.appliedMigrations(DatabaseType.H2, connection);
        assertThat(appliedMigrations, hasSize(2));
        assertThat(appliedMigrations, hasItems(v1, v2));
View Full Code Here

 
  protected void checkDaoConfig() {
    super.checkDaoConfig();
    if(dialect == null) throw new IllegalStateException("'dialect' property must be not null");
    log.info("use jdbc dialect:"+dialect);
    simpleJdbcTemplate = new SimpleJdbcTemplate(getJdbcTemplate());
    namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate());
  }
View Full Code Here

        }
        else {
          throw new IOException("Cannot save sample - invalid field:" + sample.toString());
        }
      }
      SimpleJdbcTemplate sTemplate = new SimpleJdbcTemplate(template);
      return sTemplate.batchUpdate(SAMPLE_UPDATE, batch.toArray(new SqlParameterSource[samples.size()]));
    }
    catch (MisoNamingException e) {
      throw new IOException("Cannot save sample - issue with naming scheme", e);
    }
  }
View Full Code Here

  @Override
  public void setDataSource(DataSource dataSource) {
    super.setDataSource(dataSource);
    // JdbcTemplate will be identically configured
    this.simpleJdbcTemplate = new SimpleJdbcTemplate(this.jdbcTemplate);
  }
View Full Code Here

   private SimpleJdbcInsert bookInsert;

   @Autowired(required = true)
   public void initialize(final DataSource dataSource) {
      this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
      this.bookInsert = new SimpleJdbcInsert(dataSource).withTableName("books")
            .usingGeneratedKeyColumns("id");
   }
View Full Code Here

    private SimpleJdbcTemplate simpleJdbcTemplate;
    private int counter = 0;
   
    protected void runSql(final String sql) {
        if (simpleJdbcTemplate == null) {
            simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
        }
        SimpleJdbcTestUtils.executeSqlScript(simpleJdbcTemplate, new ByteArrayResource(sql.getBytes()), false);
    }
View Full Code Here

      try {
        conn = this.dataSource.getConnection();
        //The order of these tests is IMPORTANT, each may depend on the
        //results of the previous tests.
        this.getMetaData(conn);
        final SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(this.dataSource);
       
        this.testDatabaseInitialized(jdbcTemplate);
        if (this.portalTablesExist) {
            this.testOuterJoins(jdbcTemplate);
            this.testTimeStamp(jdbcTemplate);
View Full Code Here

    private SimpleJdbcTemplate simpleJdbcTemplate;
   

    @Before
    public void onSetUp() throws Exception {
        this.simpleJdbcTemplate = new SimpleJdbcTemplate(jdbcOperations);
       
        jdbcOperations.update("CREATE TABLE UP_SEQUENCE (SEQUENCE_NAME VARCHAR(1000), SEQUENCE_VALUE INTEGER)");
        assertEquals(0, SimpleJdbcTestUtils.countRowsInTable(this.simpleJdbcTemplate, "UP_SEQUENCE"));
    }
View Full Code Here

  /**
   * Set the DataSource, typically provided via Dependency Injection.
   */
  @Autowired
  public void setDataSource(DataSource dataSource) {
    this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.simple.SimpleJdbcTemplate

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.