List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate
public JdbcTemplate(DataSource dataSource)
From source file:commonline.query.gui.action.ClearDatabaseAction.java
public void actionPerformed(ActionEvent actionEvent) { if (JOptionPane.showConfirmDialog(parent, "Are you sure you want to clear the databases?", "Clear DB", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) { SwingWorker worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws Exception { for (RecordParserDataSource dataSource : dataSources) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); for (RecordLayoutTableInfo tableInfo : dataSource.getTableInfos()) { try { jdbcTemplate.execute("delete from " + tableInfo.getTableName()); } catch (Exception err) { throw new RuntimeException("Problem clearing table:" + tableInfo.getTableName() + ", in DB:" + dataSource.getUrl(), err); }/* w ww .j a v a 2s . c o m*/ } } return null; } }; worker.execute(); } }
From source file:io.github.benas.jql.core.DatabaseInitializer.java
public DatabaseInitializer(File databaseDirectory) { this.databaseDirectory = databaseDirectory; DataSource dataSource = getDataSourceFrom(databaseDirectory); jdbcTemplate = new JdbcTemplate(dataSource); }
From source file:org.smart.migrate.dao.impl.DefaultImportDao.java
public DefaultImportDao(DataSource sourceDataSource, DataSource targetDataSource, ImportLogger importLogger) { sourceJdbcTemplate = null;//from w w w .j ava 2 s. c o m targetJdbcTemplate = null; if (sourceDataSource != null) { sourceJdbcTemplate = new JdbcTemplate(sourceDataSource); } if (targetDataSource != null) { targetJdbcTemplate = new JdbcTemplate(targetDataSource); } this.importLogger = importLogger; }
From source file:ru.org.linux.spring.dao.DeleteInfoDao.java
@Autowired public void setJdbcTemplate(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); }
From source file:com.example.ClientDetailsController.java
public ClientDetailsController(DataSource dataSource) { this.template = new JdbcTemplate(dataSource); this.clients = new JdbcClientDetailsService(dataSource); }
From source file:org.activiti.spring.test.transaction.SpringTransactionIntegrationTest.java
@Deployment public void testRollbackTransactionOnActivitiException() { // Create a table that the userBean is supposed to fill with some data JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.execute("create table MY_TABLE (MY_TEXT varchar);"); // The hello() method will start the process. The process will wait in a user task userBean.hello();// ww w.j av a 2 s.c o m assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE")); // The completeTask() method will write a record to the 'MY_TABLE' table and complete the user task try { userBean.completeTask(taskService.createTaskQuery().singleResult().getId()); fail(); } catch (Exception e) { } // Since the service task after the user tasks throws an exception, both // the record and the process must be rolled back ! assertEquals("My Task", taskService.createTaskQuery().singleResult().getName()); assertEquals(0, jdbcTemplate.queryForLong("select count(*) from MY_TABLE")); // Cleanup jdbcTemplate.execute("drop table MY_TABLE if exists;"); }
From source file:edu.harvard.i2b2.crc.dao.setfinder.QueryStatusTypeSpringDao.java
public QueryStatusTypeSpringDao(DataSource dataSource, DataSourceLookup dataSourceLookup) { setDataSource(dataSource);// w ww . ja va 2 s .c o m setDbSchemaName(dataSourceLookup.getFullSchema()); jdbcTemplate = new JdbcTemplate(dataSource); this.dataSourceLookup = dataSourceLookup; }
From source file:com.company.project.service.dao.UserDao.java
public int insert(String username, String password) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); int result = jdbcTemplate.update("insert into users (username, password) values (?, ?)", username, password);//from ww w . j a v a 2 s . c o m return result; }
From source file:com.dai.dao.EquipaAdversariaDaoImpl.java
@Override public List<EquipaAdversaria> listaEAporEscalao(int idEscalao) { List<EquipaAdversaria> eaList = new ArrayList(); String sql = "select * from equipaAdversaria where escalao_idEscalao_ea = " + idEscalao; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); eaList = jdbcTemplate.query(sql, new EquipaAdversariaRowMapper()); return eaList; }
From source file:org.hbird.business.archive.jdbc.Retriever.java
/** * Constructor. Extracts the connection to the database from * the DataSource./*from w w w . j a va 2 s. c o m*/ * * @param dataSource * The database to retrieve the parameters from. * @param destination * Name of the destination to send the retrieved * parameters to, e.g. 'activemq:queue:replay'. */ public Retriever(DataSource dataSource, String destination) { template = new JdbcTemplate(dataSource); this.destination = destination; }