List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate
public JdbcTemplate(DataSource dataSource)
From source file:org.marccarre.spring.db.testing.FooDao.java
public FooDao(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); }
From source file:org.wte4j.examples.showcase.server.config.DatabaseConfigTest.java
@Test public void databaseIsIntializedTest() { JdbcTemplate template = new JdbcTemplate(ds); Set<String> wte4jTables = template.execute(new ConnectionCallback<Set<String>>() { @Override/* ww w . j a v a2 s . c o m*/ public Set<String> doInConnection(Connection con) throws SQLException, DataAccessException { Set<String> tableNames = new HashSet<String>(); ResultSet tableRs = con.getMetaData().getTables(null, null, null, new String[] { "TABLE" }); try { while (tableRs.next()) { tableNames.add(tableRs.getString("TABLE_NAME").toLowerCase()); } } finally { tableRs.close(); } return tableNames; } }); assertEquals(6, wte4jTables.size()); assertTrue(wte4jTables.contains("person")); assertTrue(wte4jTables.contains("purchase_order")); assertTrue(wte4jTables.contains("wte4j_template")); assertTrue(wte4jTables.contains("wte4j_template_properties")); assertTrue(wte4jTables.contains("wte4j_gen")); assertTrue(wte4jTables.contains("wte4j_template_content_mapping")); }
From source file:com.springsource.greenhouse.invite.JdbcInviteRepositoryTest.java
public JdbcInviteRepositoryTest() { EmbeddedDatabase db = new GreenhouseTestDatabaseBuilder().member().activity().invite().testData(getClass()) .getDatabase();// w ww. java 2 s.c om transactional = new Transactional(db); jdbcTemplate = new JdbcTemplate(db); JdbcActionRepository actionRepository = new JdbcActionRepository(jdbcTemplate, new ActionGateway() { public void actionPerformed(Action action) { } }); inviteRepository = new JdbcInviteRepository(jdbcTemplate, actionRepository); }
From source file:org.ambraproject.doi.BaseResolverTest.java
@BeforeClass public void createDB() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUrl("jdbc:hsqldb:mem:testdb"); dataSource.setUsername("sa"); dataSource.setPassword(""); this.dataSource = dataSource; jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.execute("drop table if exists annotation;" + "drop table if exists article;" + "create table article (" + " articleID bigint not null," + " doi varchar(255) not null," + " primary key (articleID)" + ");" + "create table annotation (" + " annotationID bigint not null," + " annotationURI varchar(255) not null," + " articleID bigint null," + " type varchar(16) default null," + " primary key (annotationID)" + ");" + "alter table annotation add foreign key (articleID) references article (articleID);"); }
From source file:com.googlecode.starflow.core.key.impl.DefaultUniqueTableApp.java
public DefaultUniqueTableApp(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); this.selectSQL = "SELECT code FROM WF_PRIMARYKEY WHERE name = ? FOR UPDATE"; this.updateSQL = "UPDATE WF_PRIMARYKEY SET code = code + ? WHERE name = ? "; this.insertSQL = "INSERT INTO WF_PRIMARYKEY (code, name) VALUES (?, ?)"; }
From source file:eionet.transfer.dao.MetadataServiceJdbc.java
@Override public void save(Upload upload) { String query = "INSERT INTO uploads (id, expires, filename, uploader, contenttype, filesize) VALUES (?, ?, ?, ?, ?, ?)"; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.update(query, upload.getId(), upload.getExpires(), upload.getFilename(), upload.getUploader(), upload.getContentType(), upload.getSize()); }
From source file:com.github.dactiv.fear.commons.test.ServiceTestCaseSupport.java
@Autowired public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; this.jdbcTemplate = new JdbcTemplate(dataSource); }
From source file:io.spring.marchmadness.configuration.TaskConfiguration.java
@Bean public JdbcOperations jdbcTemplate() { return new JdbcTemplate(this.dataSource); }
From source file:no.magott.training.ex2.ExchangeRateProducerItemProcessor.java
@Override public ExchangeRate process(ExchangeRate item) throws Exception { String from = item.getFrom(); String to = item.getTo();//from w w w . j a v a 2s . c o m List<Long> list = new JdbcTemplate(dataSource).queryForList(FIND_EXCHANGE_RATE, Long.class, to, from, item.getDate()); if (!CollectionUtils.isEmpty(list)) { logger.trace("There already was a reversed entry for " + from + ":" + "to"); return null; } ExchangeRate exchangeRate = new ExchangeRate(); exchangeRate.setTo(from); exchangeRate.setFrom(to); exchangeRate.setDate(item.getDate()); exchangeRate.setExchangeRate(1 / item.getExchangeRate()); return exchangeRate; }
From source file:com.iucosoft.eavertizare.dao.impl.ConfiguratiiDaoImpl.java
@Override public void update(Configuratii config) { String query = "update configuratii_db set driver=?, url_db=?, username=?, " + "password=?, tabela_clienti=? where id=?"; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); Object[] args = new Object[] { config.getDriver(), config.getUrlDb(), config.getUsername(), config.getPassword(), config.getTabelaClienti(), config.getId() }; jdbcTemplate.update(query, args);//from www.j a va 2 s . com }