List of usage examples for org.springframework.jdbc.datasource DataSourceTransactionManager DataSourceTransactionManager
public DataSourceTransactionManager(DataSource dataSource)
From source file:org.opendatakit.persistence.engine.pgres.DatastoreImpl.java
public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; this.tm = new DataSourceTransactionManager(dataSource); }
From source file:com.springsource.html5expense.config.BatchConfig.java
@Bean public JobRepositoryFactoryBean jobRepository() throws Exception { JobRepositoryFactoryBean bean = new JobRepositoryFactoryBean(); bean.setTransactionManager(new DataSourceTransactionManager(dataSourceConfig.dataSource())); bean.setDataSource(dataSourceConfig.dataSource()); return bean;//w ww . j av a 2 s . c o m }
From source file:edu.wisc.jmeter.dao.JdbcMonitorDao.java
public JdbcMonitorDao(DataSource dataSource, int purgeOldFailures, int purgeOldStatus) { this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); final DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager( dataSource);/*from w w w . jav a2 s . com*/ dataSourceTransactionManager.afterPropertiesSet(); this.transactionTemplate = new TransactionTemplate(dataSourceTransactionManager); this.transactionTemplate.afterPropertiesSet(); this.purgeOldFailure = TimeUnit.MILLISECONDS.convert(purgeOldFailures, TimeUnit.MINUTES); this.purgeOldStatus = TimeUnit.MILLISECONDS.convert(purgeOldStatus, TimeUnit.MINUTES); }
From source file:dk.nsi.haiba.lprimporter.integrationtest.LPRIntegrationTestConfiguration.java
@Bean public PlatformTransactionManager miniPasTransactionManager(@Qualifier("lprDataSourceMinipas") DataSource ds) { return new DataSourceTransactionManager(ds); }
From source file:com.baifendian.swordfish.dao.datasource.DatabaseConfiguration.java
@Primary @Bean(name = "TransactionManager") public PlatformTransactionManager transactionManager() throws SQLException { return new DataSourceTransactionManager(dataSource()); }
From source file:org.ohmage.query.impl.AnnotationQueries.java
@Override public void createSurveyResponseAnnotation(final UUID annotationId, final String client, final Long time, final DateTimeZone timezone, final String annotationText, final UUID surveyId) throws DataAccessException { // Create the transaction. DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("Creating a new survey response annotation."); try {//w w w .j a v a 2s.com // Begin the transaction. PlatformTransactionManager transactionManager = new DataSourceTransactionManager(getDataSource()); TransactionStatus status = transactionManager.getTransaction(def); long id = 0; try { id = insertAnnotation(annotationId, time, timezone, client, annotationText); } catch (org.springframework.dao.DataAccessException e) { transactionManager.rollback(status); throw new DataAccessException("Error while executing SQL '" + SQL_INSERT_ANNOTATION + "' with parameters: " + annotationId + ", " + time + ", " + timezone.getID() + ", " + client + ", " + ((annotationText.length() > 25) ? annotationText.substring(0, 25) + "..." : annotationText), e); } try { // Insert the link between the survey_response and its annotation getJdbcTemplate().update(SQL_INSERT_SURVEY_RESPONSE_ANNOTATION, surveyId.toString(), id); } catch (org.springframework.dao.DataAccessException e) { transactionManager.rollback(status); throw new DataAccessException("Error while executing SQL '" + SQL_INSERT_SURVEY_RESPONSE_ANNOTATION + "' with parameters: " + surveyId.toString() + ", " + id, e); } // Commit the transaction. try { transactionManager.commit(status); } catch (TransactionException e) { transactionManager.rollback(status); throw new DataAccessException("Error while committing the transaction.", e); } } catch (TransactionException e) { throw new DataAccessException("Error while attempting to rollback the transaction.", e); } }
From source file:com.zzqfsy.config.mysql.MyBatisConfig.java
@Bean @Autowired// w w w. j a va 2 s . c om public DataSourceTransactionManager transactionManager(@Qualifier("dataSource") DataSource dataSource) { return new DataSourceTransactionManager(getLog4jdbcProxyDataSource(dataSource)); }
From source file:com.company.project.config.DataConfig.java
@Bean(name = "transactionManager") public DataSourceTransactionManager transactionManager() { return new DataSourceTransactionManager(dataSource()); }