Example usage for org.springframework.jdbc.core JdbcTemplate JdbcTemplate

List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate

Introduction

In this page you can find the example usage for org.springframework.jdbc.core JdbcTemplate JdbcTemplate.

Prototype

public JdbcTemplate(DataSource dataSource) 

Source Link

Document

Construct a new JdbcTemplate, given a DataSource to obtain connections from.

Usage

From source file:io.pivotal.spring.xd.jdbcgpfdist.support.LoadFactoryBean.java

@Override
public void afterPropertiesSet() throws IOException {
    Assert.notNull(dataSource, "DataSource must not be null.");
    Assert.notNull(loadConfiguration, "Load configuration must not be null.");
    jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:cc.notsoclever.examples.DatabaseBean.java

public void destroy() throws Exception {
    JdbcTemplate jdbc = new JdbcTemplate(dataSource);

    try {//w  ww.  j  a  v  a  2 s . co  m
        jdbc.execute("drop table company");
    } catch (Throwable e) {
        // ignore
    }
}

From source file:com.springsource.open.foo.async.AbstractAsynchronousMessageTriggerTests.java

@Autowired
public void setDataSource(@Qualifier("dataSource") DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:org.easybatch.test.common.AbstractDatabaseTest.java

protected void setUp() throws Exception {
    embeddedDatabase = embeddedDatabaseBuilder.build();
    jdbcTemplate = new JdbcTemplate(embeddedDatabase);
}

From source file:org.anon.logic.map.TwoTablesAllDbTest.java

protected JdbcTemplate getJdbcTemplate() {
    if (jdbcTemplate == null) {
        jdbcTemplate = new JdbcTemplate(getDataSource());
        jdbcTemplate.execute(database.getDatabaseSpecifics().getUseSchemaSql(schema));
    }/*from   w ww.j a v  a  2s  .  c om*/
    return jdbcTemplate;
}

From source file:com.gvmax.data.user.JDBCBasedUserDAO.java

public JDBCBasedUserDAO(DataSource dataSource, String encKey) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    this.enc = new Enc(encKey);
}

From source file:com.redpill_linpro.springframework.beans.factory.config.JdbcPlaceholderConfigurer.java

/**
 * Set the data source to be used to look up properties.
 *//*from  w ww. j  a  v  a 2s .c o m*/
public void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:org.obiba.runtime.upgrade.support.JdbcVersionModifier.java

@Override
public void afterPropertiesSet() throws Exception {
    jdbcTemplate = new JdbcTemplate(datasource);

    try {/*from  w w  w. j a v  a2  s.com*/
        log.info("Attempting to retrieve the currently running version information from the database...");
        List<Map<String, Object>> result = jdbcTemplate.queryForList("select * from version");
        if (result != null && result.size() > 0) {
            Map<String, Object> versionInfo = result.get(0);
            String major = versionInfo.get("major").toString();
            String minor = versionInfo.get("minor").toString();
            String micro = versionInfo.get("micro").toString();
            String qualifier = versionInfo.get("qualifier").toString();
            setVersion(new Version(Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(micro),
                    qualifier));
            log.info("The current version is {} ", version);
        }
    } catch (DataAccessException e) {
        log.warn(
                "Could not retrieve the current version. This looks like a new installation, so no upgrades are needed.",
                e);
    }

}

From source file:com.demo.camelrestsqldemo.DatabaseBean.java

public void destroy() throws Exception {
    JdbcTemplate jdbc = new JdbcTemplate(dataSource);

    try {//from  www.j  a  v  a2 s  .com
        jdbc.execute("drop table orders");
    } catch (Throwable e) {
        // ignore
    }
}

From source file:info.novatec.flyway.branching.extension.BranchingMigrationPostgresqlIntegrationTest.java

/**
 * Cleaning up the test database./* ww w  . j a  v a  2s. co m*/
 * @throws InterruptedException if thread is interrupted
 */
@After
public final void cleanup() throws InterruptedException {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(getDatasource());
    try {
        jdbcTemplate.update("drop table person");
    } catch (DataAccessException e) {
        // No OP
    }
    try {
        jdbcTemplate.update("drop table releasetable");
    } catch (DataAccessException e) {
        // No OP
    }
    try {
        jdbcTemplate.update("drop table schema_version");
    } catch (DataAccessException e) {
        // No OP
    }
}