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.stehno.test.TestDatabase.java

@Override
protected void before() throws Throwable {
    // org.h2.Driver
    jdbcTemplate = new JdbcTemplate(new DriverManagerDataSource("jdbc:h2:~/test", "sa", ""));

    namedJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);

    jdbcTemplate.execute(// ww  w. j  a  v a2s  .c o m
            "create table people (id int AUTO_INCREMENT primary key, first_name varchar(40), last_name varchar(40), age int)");
}

From source file:com.unito.repository.JDBCConfig.java

@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
    return new JdbcTemplate(dataSource);
}

From source file:com.ccoe.build.dal.PluginJDBCTemplate.java

public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    this.jdbcTemplateObject = new JdbcTemplate(dataSource);
}

From source file:test.service.SearchBankServiceTest.java

@Before
public void init() {
    JdbcTemplate jdbc = new JdbcTemplate(dataSource);
    jdbc.execute("delete from banktable");
    banks = creatListOfBanks();//from w  w w. j  av  a  2s .  c om
    bankDao.updateDB(banks);
}

From source file:co.jirm.spring.SpringJirmFactory.java

@Autowired
public SpringJirmFactory(DataSource dataSource) {
    jdbcTemplate = new JdbcTemplate(dataSource);
    ormConfigSupplier = Suppliers.memoize(new Supplier<OrmConfig>() {
        @Override/*from  w w w . j  a  v  a 2 s .co m*/
        public OrmConfig get() {
            return SpringJirmFactory.this.createOrmConfig();
        }
    });
    sqlExecutorSupplier = Suppliers.memoize(new Supplier<SqlExecutor>() {
        @Override
        public SqlExecutor get() {
            return SpringJirmFactory.this.createSqlExecutor();
        }
    });
}

From source file:org.ambraproject.doi.JdbcResolverService.java

public JdbcResolverService(DataSource dataSource) {
    jdbcTemplate = new JdbcTemplate(dataSource);
}

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

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

    String sql = "create table company (\n"
            + "  ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),\n"
            + "  name varchar(30),\n" + "  symbol varchar(10)\n" + ")";

    LOG.info("Creating table company ...");

    try {/*from  w w  w .j a v  a 2  s. c om*/
        jdbc.execute("drop table company");
    } catch (Throwable e) {
        // ignore
    }

    jdbc.execute(sql);

    LOG.info("... created table company");
}

From source file:com.beezas.dao.EventDaoImpl.java

public List<User> getCategories() {
    List categoryList = new ArrayList();
    String sql = "select * from category";
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    categoryList = jdbcTemplate.query(sql, new UserRowMapper());
    return categoryList;
}

From source file:com.aw.core.db.DbCachedTime.java

protected Date queryDBForSysdate() {
    return (Date) TransactionDecorator.executeQuery(new DBExecuter() {
        public Object execute() {
            JdbcTemplate jt = new JdbcTemplate(dataSource);
            String sql = "select sysdate from dual";
            Date date = (Date) jt.queryForObject(sql, Date.class);
            return date;
        }//from   w  w w. jav  a2  s .c o m
    });
}

From source file:com.springsource.open.db.DatasourceTests.java

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