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:com.univocity.examples.Tutorial006JdbcConfigurationOptions.java

@Override
protected JdbcDataStoreConfiguration newDatabaseConfiguration() {
    JdbcDataStoreConfiguration database = super.newDatabaseConfiguration();

    //##CODE_START
    //Let's add new columns to store uniVocity's data to track generated IDs
    new JdbcTemplate(dataSource).update("ALTER TABLE locale ADD id_tracker INTEGER");
    new JdbcTemplate(dataSource).update("ALTER TABLE locale ADD process_id INTEGER");

    //The "locale" table also works with logical exclusion.
    new JdbcTemplate(dataSource).update("ALTER TABLE locale ADD deleted CHAR(1) DEFAULT 'N' NOT NULL");

    JdbcEntityConfiguration config = database.getEntityConfiguration("locale");
    //Here we configure the locale entity to use 2 numeric columns to allow batch inserts
    //After each batch, uniVocity will fetch the ID's generated for each row using the information stored in these columns.
    config.retrieveGeneratedKeysUsingNumericColumns("process_id", "id_tracker", "id");

    //We also define a custom SQL producer to generate proper SELECT statements that
    //take into account the logical exclusion implemented for the locale table..
    config.setSqlProducer(new LogicalExclusionSelect());

    //##CODE_END/*w ww .j a  v a 2s .com*/
    return database;
}

From source file:com.fusesource.examples.horo.db.HoroscopeUtils.java

public HoroscopeUtils(DataSource dataSource) {
    Validate.notNull(dataSource, "dataSource is null");
    this.jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:org.beast.project.template.config.JDBCConfig.java

@Bean(initMethod = "setup", destroyMethod = "cleanup")
@Autowired// w  ww  .  j  a va 2s  .c o  m
public JdbcTemplate jdbcTemplate(DataSource ds) {
    return new JdbcTemplate(ds);
}

From source file:Poll_Ans_Tbl.Poll_Ans_TblJDBCTemplate.java

public Poll_Ans_TblJDBCTemplate() throws SQLException {
    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    conn = (connectivity) context.getBean("connectivity");

    this.dataSource = conn.getDataSource();
    this.jdbcTemplateObject = new JdbcTemplate(dataSource);

}

From source file:com.ewcms.component.auth.dao.UserDAO.java

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

From source file:com.jaxio.celerio.configuration.database.mysql.MySqlEnumExtractorTest.java

private JdbcTemplate jdbcTemplate() {
    return new JdbcTemplate(
            new SingleConnectionDataSource("jdbc:mysql://localhost/sakila", "root", "root", true));
}

From source file:com.uit.anonymousidentity.Repository.Nonces.NonceJDBCTemplate.java

@Autowired
public void setDataSource(DataSource dataSource) throws SQLException {
    this.dataSource = dataSource;
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    createTableIfNotExist();/*from   w  w  w . ja  v a 2  s .com*/
}

From source file:com.dai.dao.TreinoDaoImpl.java

@Override
public void inserirTreino(Treino treino) {

    String sql = "INSERT INTO treino "
            + "( duracaoTreino, localTreino, dataTreino, tipoTreino, horaTreino, escalao_idEscalao_t) VALUES (?, ?, ?, ?,?, ?)";

    JdbcTemplate template = new JdbcTemplate(dataSource);

    template.update(sql, new Object[] { treino.getDuracaoTreino(), treino.getLocalTreino(),
            treino.getDataTreino(), treino.getTipoTreino(), treino.getHoraTreino(), treino.getIdEscalao() });

}

From source file:Category_Manager.Category_TblJDBCTemplate.java

public Category_TblJDBCTemplate() throws SQLException {
    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    conn = (connectivity) context.getBean("connectivity");

    this.dataSource = conn.getDataSource();
    this.jdbcTemplateObject = new JdbcTemplate(dataSource);

}

From source file:com.onclave.testbench.jdbcTemplate.DAOSupport.StudentDAOImplementation.java

@Autowired
public StudentDAOImplementation(DataSource dataSource) {
    this.jdbcTemplate = (new JdbcTemplate(dataSource));
}