List of usage examples for javax.sql DataSource toString
public String toString()
From source file:org.ala.dao.VocabularyDAOImpl.java
/** * Constructor to set DataSource via DI// www . ja va 2s . co m * * @param dataSource the DataSource to inject */ @Inject public VocabularyDAOImpl(DataSource dataSource) { this.setDataSource(dataSource); logger.debug("Vocabulary initialising... " + dataSource.toString()); }
From source file:org.ala.dao.InfoSourceDAOImpl.java
/** * Constructor to set DataSource via DI// w ww . j av a2 s. c o m * * @param dataSource the DataSource to inject */ @Inject public InfoSourceDAOImpl(DataSource dataSource) { this.setDataSource(dataSource); logger.debug("InfoSource initialising... " + dataSource.toString()); }
From source file:fr.paris.lutece.portal.service.jpa.JPAStartupService.java
/** * Initialize JPA objects (Datasource, Persistence Unit Manager, Entity Manager Factory, * Transaction Manager) for each pool./* w w w .ja v a2s . co m*/ */ public void process() { ReferenceList list = new ReferenceList(); AppConnectionService.getPoolList(list); Map<String, EntityManagerFactory> mapFactories = new HashMap<String, EntityManagerFactory>(); List<PlatformTransactionManager> listTransactionManagers = new ArrayList<PlatformTransactionManager>(); _log.info("JPA Startup Service : Initializing JPA objects ..."); String strDialectProperty = AppPropertiesService.getProperty(JPA_DIALECT_PROPERTY); for (ReferenceItem poolItem : list) { String strPoolname = poolItem.getCode(); DataSource ds = AppConnectionService.getPoolManager().getDataSource(strPoolname); _log.info("JPA Startup Service : DataSource retrieved for pool : " + strPoolname); _log.debug("> DS : " + ds.toString()); DefaultPersistenceUnitManager pum = new DefaultPersistenceUnitManager(); pum.setDefaultDataSource(ds); PersistenceUnitPostProcessor[] postProcessors = { new JPAPersistenceUnitPostProcessor() }; pum.setPersistenceUnitPostProcessors(postProcessors); pum.afterPropertiesSet(); _log.info("JPA Startup Service : Persistence Unit Manager for pool : " + strPoolname); _log.debug("> PUM : " + pum.toString()); LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean(); lcemfb.setDataSource(ds); lcemfb.setPersistenceUnitManager(pum); lcemfb.setPersistenceUnitName("jpaLuteceUnit"); JpaDialect jpaDialect = (JpaDialect) SpringContextService.getBean("jpaDialect"); lcemfb.setJpaDialect(jpaDialect); Map mapJpaProperties = (Map) SpringContextService.getBean("jpaPropertiesMap"); lcemfb.setJpaPropertyMap(mapJpaProperties); String strDialect = AppPropertiesService.getProperty(poolItem.getName() + ".dialect"); // replace default dialect if <poolname>.dialect is specified if (StringUtils.isNotBlank(strDialect)) { mapJpaProperties.put(strDialectProperty, strDialect); } _log.debug("Using dialect " + mapJpaProperties.get(strDialectProperty) + " for pool " + poolItem.getName()); JpaVendorAdapter jpaVendorAdapter = (JpaVendorAdapter) SpringContextService.getBean("jpaVendorAdapter"); lcemfb.setJpaVendorAdapter(jpaVendorAdapter); lcemfb.afterPropertiesSet(); EntityManagerFactory emf = lcemfb.getNativeEntityManagerFactory(); _log.info("JPA Startup Service : EntityManagerFactory created for pool : " + strPoolname); _log.debug("> EMF : " + emf.toString()); JpaTransactionManager tm = new JpaTransactionManager(); tm.setEntityManagerFactory(emf); tm.setJpaDialect(jpaDialect); _log.debug("> JpaDialect " + jpaDialect); tm.afterPropertiesSet(); _log.info("JPA Startup Service : JPA TransactionManager created for pool : " + strPoolname); _log.debug("> TM : " + tm.toString()); mapFactories.put(strPoolname, emf); listTransactionManagers.add(tm); } EntityManagerService ems = (EntityManagerService) SpringContextService.getBean("entityManagerService"); ems.setMapFactories(mapFactories); ChainedTransactionManager ctm = (ChainedTransactionManager) SpringContextService .getBean("transactionManager"); ctm.setTransactionManagers(listTransactionManagers); _log.info("JPA Startup Service : completed successfully"); }
From source file:au.org.ala.layers.dao.LayerDAOImpl.java
@Resource(name = "dataSource") public void setDataSource(DataSource dataSource) { logger.info("setting data source in layers-store.layersDao"); if (dataSource != null) { logger.info("dataSource is NOT null"); logger.info(dataSource.toString()); } else {/*from w ww .jav a 2s .c o m*/ logger.info("dataSource is null"); } this.dataSource = dataSource; this.jdbcTemplate = new SimpleJdbcTemplate(dataSource); this.insertLayer = new SimpleJdbcInsert(dataSource).withTableName("layers").usingGeneratedKeyColumns("id"); }
From source file:com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorAutoConfigurationTests.java
@Test void testDecoratingChainBuiltCorrectly() { contextRunner.run(context -> {/* w w w . j ava 2 s . c o m*/ DataSource dataSource = context.getBean(DataSource.class); DecoratedDataSource dataSource1 = context.getBean(DecoratedDataSource.class); assertThat(dataSource1).isNotNull(); DataSource p6DataSource = dataSource1.getDecoratedDataSource(); assertThat(p6DataSource).isNotNull(); assertThat(p6DataSource).isInstanceOf(P6DataSource.class); DataSource proxyDataSource = (DataSource) new DirectFieldAccessor(p6DataSource) .getPropertyValue("realDataSource"); assertThat(proxyDataSource).isNotNull(); assertThat(proxyDataSource).isInstanceOf(ProxyDataSource.class); DataSource flexyDataSource = (DataSource) new DirectFieldAccessor(proxyDataSource) .getPropertyValue("dataSource"); assertThat(flexyDataSource).isNotNull(); assertThat(flexyDataSource).isInstanceOf(FlexyPoolDataSource.class); DataSource realDataSource = (DataSource) new DirectFieldAccessor(flexyDataSource) .getPropertyValue("targetDataSource"); assertThat(realDataSource).isNotNull(); assertThat(realDataSource).isInstanceOf((Class<? extends DataSource>) HikariDataSource.class); assertThatDataSourceDecoratingChain(dataSource).containsExactly(P6DataSource.class, ProxyDataSource.class, FlexyPoolDataSource.class); assertThat(dataSource.toString()) .isEqualTo("p6SpyDataSourceDecorator [com.p6spy.engine.spy.P6DataSource] -> " + "proxyDataSourceDecorator [net.ttddyy.dsproxy.support.ProxyDataSource] -> " + "flexyPoolDataSourceDecorator [com.vladmihalcea.flexypool.FlexyPoolDataSource] -> " + "dataSource [com.zaxxer.hikari.HikariDataSource]"); }); }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public PMDbDao() throws I2B2Exception { DataSource ds = null; Connection conn = null;/*w w w . j a v a2 s .c o m*/ try { ds = PMUtil.getInstance().getDataSource("java:/PMBootStrapDS"); // database = ds.getConnection().getMetaData().getDatabaseProductName(); log.debug(ds.toString()); } catch (I2B2Exception e2) { log.error("bootstrap ds failure: " + e2.getMessage()); throw e2; // } catch (SQLException e2) { // log.error("bootstrap ds failure: " + e2.getMessage()); //throw e2; } try { conn = ds.getConnection(); database = conn.getMetaData().getDatabaseProductName(); conn.close(); conn = null; } catch (Exception e) { conn = null; log.error("Error geting database name:" + e.getMessage()); } finally { conn = null; } this.jt = new SimpleJdbcTemplate(ds); // ds = null; }
From source file:org.alfresco.reporting.test.TestReporting.java
private static org.pentaho.reporting.engine.classic.core.filter.DataSource getJndiDataSource(String source) throws NamingException, RemoteException { System.out.println("enter getJndiDataSource source=" + source); ConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource(); ((MysqlDataSource) dataSource).setUser("alfrescoo"); ((MysqlDataSource) dataSource).setPassword("d=dMdva1fresco"); ((MysqlDataSource) dataSource).setServerName("localhost"); ((MysqlDataSource) dataSource).setPort(3306); ((MysqlDataSource) dataSource).setDatabaseName("alfrescoreporting"); //DataSource ds = (javax.sql.DataSource)dataSource; //Context ctx = new InitialContext(); //System.out.println("Done initialContext"); org.pentaho.reporting.engine.classic.core.filter.DataSource ds = (org.pentaho.reporting.engine.classic.core.filter.DataSource) dataSource; //ctx.lookup("ibfdReporting"); //System.out.println("Done lookup"); System.out.println(ds.toString()); //InitialContext context = createContext(); //context.rebind("java:"+source, ds); System.out.println("exit getJndiDataSource"); return ds;/*from w ww . jav a 2 s . c o m*/ }
From source file:org.kuali.rice.krad.data.platform.MaxValueIncrementerFactory.java
/** * Creates an {@link DataFieldMaxValueIncrementer} from a {@link DataSource}. * * @param dataSource the {@link DataSource} for which to retrieve the incrementer. * @param incrementerName the name of the incrementer. * @return an {@link DataFieldMaxValueIncrementer} from a {@link DataSource}. *//*from ww w .ja va 2 s . com*/ private static DataFieldMaxValueIncrementer createIncrementer(DataSource dataSource, String incrementerName) { DatabasePlatformInfo platformInfo = DatabasePlatforms.detectPlatform(dataSource); DataFieldMaxValueIncrementer incrementer = getCustomizedIncrementer(platformInfo, dataSource, incrementerName, ID_COLUMN_NAME); if (incrementer != null) { return incrementer; } if (DatabasePlatforms.ORACLE.equalsIgnoreCase(platformInfo.getName())) { incrementer = new OracleSequenceMaxValueIncrementer(dataSource, incrementerName); } else if (DatabasePlatforms.MYSQL.equalsIgnoreCase(platformInfo.getName())) { incrementer = new EnhancedMySQLMaxValueIncrementer(dataSource, incrementerName, ID_COLUMN_NAME); } if (incrementer == null) { throw new UnsupportedDatabasePlatformException(platformInfo); } if (incrementer instanceof InitializingBean) { try { ((InitializingBean) incrementer).afterPropertiesSet(); } catch (Exception e) { throw new DataAccessResourceFailureException( "Failed to initialize max value incrementer for given datasource and incrementer. dataSource=" + dataSource.toString() + ", incrementerName = " + incrementerName, e); } } return incrementer; }
From source file:org.openkoala.koala.monitor.support.JdbcPoolStatusCollector.java
/** * ???/*www.java 2 s. com*/ * @return */ public Map<String, JdbcPoolStatusVo> currentAllDataSourceStatus() { try { Map<String, JdbcPoolStatusVo> result = new HashMap<String, JdbcPoolStatusVo>(); if (collectors.isEmpty()) return result; Set<DataSource> dataSources = collectors.keySet(); for (DataSource ds : dataSources) { JdbcPoolStatusVo poolStatus = collectors.get(ds).currentPoolStatus(); addConnPoolDetails(ds, poolStatus); result.put(ds.toString(), poolStatus); } return result; } catch (Exception e) { throw new RuntimeException(e); } }