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.home.ln_spring.ch8.dao.jdbc.xml.JdbcContactDao.java

public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);

}

From source file:org.wso2.carbon.metrics.jdbc.reporter.JdbcReporterTest.java

@BeforeSuite
private static void init() throws Exception {
    dataSource = JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "");
    template = new JdbcTemplate(dataSource);
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("dbscripts/h2.sql"));
    populator.populate(dataSource.getConnection());
    DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(dataSource);
    transactionTemplate = new TransactionTemplate(dataSourceTransactionManager);
}

From source file:com.ignite.dao.ClientDao.java

@PreAuthorize("hasRole('ROLE_TELLER')")
public List<Client> getClients() {
    logger.info("Getting clients");

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    List<Client> products = jdbcTemplate.query("select firstname, lastname, username, pid from users",
            new ClientMapper());
    return products;
}

From source file:infowall.domain.persistence.sql.ItemValueDao.java

public ItemValueDao(final DataSource dataSource) {
    jdbcTemplate = new JdbcTemplate(dataSource);
    mapper = new ObjectMapper();
}

From source file:com.nebhale.cyclinglibrary.repository.JdbcTaskRepository.java

@Autowired
JdbcTaskRepository(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    this.createStatement = new SimpleJdbcInsert(dataSource).withTableName("tasks")
            .usingGeneratedKeyColumns("id");
}

From source file:com.rplt.studioMusik.pegawai.PegawaiDAO.java

@Override
public List<Pegawai> getDataList() {
    List<Pegawai> pegawaiList = new ArrayList<Pegawai>();

    String sql = "SELECT * FROM pegawai_studio_musik";

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    pegawaiList = jdbcTemplate.query(sql, new PegawaiRowMapper());
    return pegawaiList;
}

From source file:edu.harvard.i2b2.crc.dao.setfinder.XmlResultSpringDao.java

public XmlResultSpringDao(DataSource dataSource, DataSourceLookup dataSourceLookup) {
    setDataSource(dataSource);/*  w w w .  j a  va2  s .c o m*/
    setDbSchemaName(dataSourceLookup.getFullSchema());
    jdbcTemplate = new JdbcTemplate(dataSource);
    this.dataSourceLookup = dataSourceLookup;

}

From source file:org.activiti.spring.test.transaction.UserBean.java

@Transactional
public void completeTask(String taskId) {

    // First insert a record in the MY_TABLE table
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    int nrOfRows = jdbcTemplate.update("insert into MY_TABLE values ('test');");
    if (nrOfRows != 1) {
        throw new RuntimeException("Insert into MY_TABLE failed");
    }/*from www  . j a  v a  2  s.c  o  m*/

    taskService.complete(taskId);
}

From source file:com.starit.diamond.server.service.DBPersistService.java

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

From source file:com.uit.anonymousidentity.Repository.IssuerKeys.IssuerJDBCTemplate.java

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