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, boolean lazyInit) 

Source Link

Document

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

Usage

From source file:com.github.akiraly.db4j.CommonDbConfig.java

@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource, false);
    jdbcTemplate.setSkipUndeclaredResults(true);
    return jdbcTemplate;
}

From source file:test.other.T_Dao.java

public void setup() {

    try {//www.  ja  va 2s.c o m
        Class.forName("org.postgresql.Driver");
        String url = "jdbc:postgresql://localhost:5432/free-choice-v1";
        String url1 = "jdbc:postgresql://localhost:5432/test";
        conn = DriverManager.getConnection(url, "bcgh2013", "2013.bcgh.start");

        ComboPooledDataSource cpds = new ComboPooledDataSource();
        try {
            cpds.setDriverClass("org.postgresql.Driver");
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
        cpds.setJdbcUrl("jdbc:postgresql://localhost:5432/free-choice-v1");
        cpds.setUser("bcgh2013");
        cpds.setPassword("2013.bcgh.start");
        cpds.setMinPoolSize(5);
        cpds.setAcquireIncrement(5);
        cpds.setMaxPoolSize(80);
        dataSource = cpds;

        jdbcTemplate = new JdbcTemplate(dataSource, false);

    } catch (Exception e) {
        e.printStackTrace();
    }

}