List of usage examples for org.springframework.jdbc.datasource LazyConnectionDataSourceProxy LazyConnectionDataSourceProxy
public LazyConnectionDataSourceProxy(DataSource targetDataSource)
From source file:org.sbq.batch.configurations.DatabaseConfiguration.java
@Bean @Primary public DataSource dataSource() { return new LazyConnectionDataSourceProxy(dbcpDataSource()); }
From source file:cn.vko.cache.dao.rw.DefaultDataSourceService.java
@Override public void afterPropertiesSet() throws Exception { if (haDataSourceCreator == null) { setHaDataSourceCreator(new NonHADataSourceCreator()); }// w ww . ja va 2 s . c om for (DataSourceDescriptor descriptor : dataSourceDescriptors) { Validate.notEmpty(descriptor.getIdentity()); Validate.notNull(descriptor.getTarget()); DataSource dataSourceToUse = descriptor.getTarget(); if (descriptor.getStandby() != null) { dataSourceToUse = haDataSourceCreator.createHADataSource(descriptor); } dataSourceToUse = new LazyConnectionDataSourceProxy(dataSourceToUse); dataSources.put(descriptor.getIdentity(), dataSourceToUse); // if ("read".equalsIgnoreCase(descriptor.getType())) { readDataSources.add(dataSourceToUse); } else if ("write".equalsIgnoreCase(descriptor.getType())) { writeDataSources.add(dataSourceToUse); } } }
From source file:com.github.djabry.platform.service.data.config.DAOConfig.java
@Bean public DataSource dataSource() { return new LazyConnectionDataSourceProxy(dataSource.dataSource()); }
From source file:com.alibaba.cobar.client.datasources.DefaultCobarDataSourceService.java
public void afterPropertiesSet() throws Exception { if (getHaDataSourceCreator() == null) { setHaDataSourceCreator(new NonHADataSourceCreator()); }/*from w ww . j ava 2 s . c o m*/ if (CollectionUtils.isEmpty(dataSourceDescriptors)) { return; } for (CobarDataSourceDescriptor descriptor : getDataSourceDescriptors()) { Validate.notEmpty(descriptor.getIdentity()); Validate.notNull(descriptor.getTargetDataSource()); DataSource dataSourceToUse = descriptor.getTargetDataSource(); if (descriptor.getStandbyDataSource() != null) { dataSourceToUse = getHaDataSourceCreator().createHADataSource(descriptor); if (CollectionUtils.isNotEmpty(dataSourcePostProcessor)) { for (IDataSourcePostProcessor pp : dataSourcePostProcessor) { dataSourceToUse = pp.postProcess(dataSourceToUse); } } } dataSources.put(descriptor.getIdentity(), new LazyConnectionDataSourceProxy(dataSourceToUse)); } }
From source file:hub.config.connectors.PanAuditConfig.java
@Bean public LazyConnectionDataSourceProxy panAuditLazyConnectionDataSource() { return new LazyConnectionDataSourceProxy(panAuditDataSource()); }
From source file:hub.config.connectors.ProjectDbConfig.java
@Bean public LazyConnectionDataSourceProxy projectDbLazyConnectionDataSource() { return new LazyConnectionDataSourceProxy(projectDbDataSource()); }
From source file:mx.edu.um.eventosum.config.DataConfig.java
@Bean public DataSource dataSource() { LazyConnectionDataSourceProxy ds = new LazyConnectionDataSourceProxy(mainDataSource()); return ds; }
From source file:com.gopivotal.cloudfoundry.test.core.DataSourceUtilsTest.java
@Test public void lazyConnectionUrl() { BoneCPDataSource targetDataSource = new BoneCPDataSource(); targetDataSource.setJdbcUrl(TEST_URL); LazyConnectionDataSourceProxy dataSource = new LazyConnectionDataSourceProxy(targetDataSource); assertEquals(TEST_URL, this.dataSourceUtils.getUrl(dataSource)); }
From source file:nz.geek.caffe.spring.hdb.HANAExceptionMappingTest.java
/** *///w ww.ja va2 s. c om @Test public void testUnableToConnect() { final DriverManagerDataSource ds = new DriverManagerDataSource("jdbc:sap://blahhost:30115", "blah", "blah"); JdbcTemplate template = new JdbcTemplate(); template.setExceptionTranslator(new SQLErrorCodeSQLExceptionTranslator("HDB")); template.setDataSource(new LazyConnectionDataSourceProxy(ds)); template.afterPropertiesSet(); try { template.execute("SELECT 1 FROM DUMMY"); Assert.fail("connect should have failed"); } catch (final DataAccessResourceFailureException e) { // expected } }