当前位置: 首页>>代码示例>>Java>>正文


Java JndiDataSourceLookup.getDataSource方法代码示例

本文整理汇总了Java中org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java JndiDataSourceLookup.getDataSource方法的具体用法?Java JndiDataSourceLookup.getDataSource怎么用?Java JndiDataSourceLookup.getDataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup的用法示例。


在下文中一共展示了JndiDataSourceLookup.getDataSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jndiDataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean(destroyMethod="")
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException, SQLException
{
	JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
	
	DataSource ds = dataSourceLookup.getDataSource("java:comp/env/jdbc/DefaultDB");
	
	DBInformation dbInfo = new DBInformation(ds.getConnection().getMetaData());
	log.info(dbInfo.toString());
	
	return ds;
}
 
开发者ID:SAP,项目名称:cloud-spring-boot-sample,代码行数:13,代码来源:NeoConfig.java

示例2: makeDbRequest

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Override
public List<Map<String, Object>> makeDbRequest(String jndi,
		String query) {
       JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
       dsLookup.setResourceRef(true);
      
       DataSource dataSource = dsLookup.getDataSource(jndi);
       Assert.notNull(dataSource, "DataSource is null.");
       LOGGER.info("DataSource: " + dataSource);   
       
       JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
       
	LOGGER.info("Executing query:"+query);
	LOGGER.info("JdbcTemplate:"+jdbcTemplate);
       return jdbcTemplate.queryForList(query);
}
 
开发者ID:MUNDO-platform,项目名称:srccode,代码行数:17,代码来源:DbCachedServiceImpl.java

示例3: makeDbOrCache1mRequest

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Override
@Cacheable("mundoCache")
public List<Map<String, Object>> makeDbOrCache1mRequest(String jndi,
		String query) {
       JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
       dsLookup.setResourceRef(true);
      
       DataSource dataSource = dsLookup.getDataSource(jndi);
       Assert.notNull(dataSource, "DataSource is null.");
       LOGGER.info("DataSource: " + dataSource);   
       
       JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
       
	LOGGER.info("Executing query:"+query);
	LOGGER.info("JdbcTemplate:"+jdbcTemplate);
       return jdbcTemplate.queryForList(query);
}
 
开发者ID:MUNDO-platform,项目名称:srccode,代码行数:18,代码来源:DbCachedServiceImpl.java

示例4: makeDbOrCache1hRequest

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Override
@Cacheable("mundo1hCache")
public List<Map<String, Object>> makeDbOrCache1hRequest(String jndi,
		String query) {
       JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
       dsLookup.setResourceRef(true);
      
       DataSource dataSource = dsLookup.getDataSource(jndi);
       Assert.notNull(dataSource, "DataSource is null.");
       LOGGER.info("DataSource: " + dataSource);   
       
       JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
       
	LOGGER.info("Executing query:"+query);
	LOGGER.info("JdbcTemplate:"+jdbcTemplate);
       return jdbcTemplate.queryForList(query);
}
 
开发者ID:MUNDO-platform,项目名称:srccode,代码行数:18,代码来源:DbCachedServiceImpl.java

示例5: makeDbOrCache12hRequest

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Override
@Cacheable("mundo12hCache")
public List<Map<String, Object>> makeDbOrCache12hRequest(String jndi,
		String query) {
       JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
       dsLookup.setResourceRef(true);
      
       DataSource dataSource = dsLookup.getDataSource(jndi);
       Assert.notNull(dataSource, "DataSource is null.");
       LOGGER.info("DataSource: " + dataSource);   
       
       JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
       
	LOGGER.info("Executing query:"+query);
	LOGGER.info("JdbcTemplate:"+jdbcTemplate);
       return jdbcTemplate.queryForList(query);
}
 
开发者ID:MUNDO-platform,项目名称:srccode,代码行数:18,代码来源:DbCachedServiceImpl.java

示例6: makeDbOrCache24hRequest

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Override
@Cacheable("mundo24hCache")
public List<Map<String, Object>> makeDbOrCache24hRequest(String jndi,
		String query) {
       JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
       dsLookup.setResourceRef(true);
      
       DataSource dataSource = dsLookup.getDataSource(jndi);
       Assert.notNull(dataSource, "DataSource is null.");
       LOGGER.info("DataSource: " + dataSource);   
       
       JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
       
	LOGGER.info("Executing query:"+query);
	LOGGER.info("JdbcTemplate:"+jdbcTemplate);
       return jdbcTemplate.queryForList(query);
}
 
开发者ID:MUNDO-platform,项目名称:srccode,代码行数:18,代码来源:DbCachedServiceImpl.java

示例7: dataSourceJndi

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
/**
 * Creates DataSource from JNDI resource.
 * @return DataSource
 */
@Bean
public DataSource dataSourceJndi() {
    
    final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);
    DataSource dataSource = dsLookup.getDataSource(dbJndiName);
    return dataSource;
}
 
开发者ID:MUNDO-platform,项目名称:srccode,代码行数:13,代码来源:PersistenceConfig.java

示例8: dataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Primary
@Bean(destroyMethod = "")
public DataSource dataSource() {
    log.debug("Configuring Datasource");

    if (propertyResolver.getProperty("url") == null && propertyResolver.getProperty("jndi") == null) {
        log.error("Your database connection pool configuration is incorrect! The application" +
            "cannot start. Please check your Spring profile, current profiles are: {}");

        throw new ApplicationContextException("Database connection pool is not configured correctly");
    }

    try {
        String jndi = propertyResolver.getProperty("jndi");

        if (jndi != null) {
            log.debug("Getting datasource from JNDI global resource link {}", jndi);
            JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
            return dataSourceLookup.getDataSource(jndi);
        } else {

            String url = propertyResolver.getProperty("url");
            String username = propertyResolver.getProperty("username");

            log.debug("Initializing PGPoolingDataSource: url={}, username={}", url, username);
            PGPoolingDataSource source = new PGPoolingDataSource();
            source.setUrl(url);
            source.setUser(username);
            source.setPassword(propertyResolver.getProperty("password"));
            source.setMaxConnections(10);
            return source;
        }
    } catch (Exception e) {
        log.error("dataSource: msg=" + e.getMessage(), e);
        throw new ApplicationContextException("Database connection pool creation resulted in error");
    }
}
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:38,代码来源:DatabaseConfiguration.java

示例9: dataSourceEcandidat

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
/**
 * @return Source de données
 */
@Bean
public DataSource dataSourceEcandidat() {
	JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
	return dsLookup.getDataSource("java:/comp/env/jdbc/dbEcandidat");
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:9,代码来源:JpaConfigEcandidat.java

示例10: bookManagerDataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource bookManagerDataSource() {
	JndiDataSourceLookup lookup = new JndiDataSourceLookup();
	return lookup.getDataSource("jdbc/bookManager");
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:6,代码来源:RootApplicationContextConfig.java

示例11: dataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
  final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
  dsLookup.setResourceRef(true);
  return dsLookup.getDataSource(JNDI_DATA_SOURCE);
}
 
开发者ID:epam-debrecen-rft-2015,项目名称:atsy,代码行数:7,代码来源:PersistenceConfiguration.java

示例12: dataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingClass(name = "it.cineca.pst.huborcid.config.HerokuDatabaseConfiguration")
@Profile("!" + Constants.SPRING_PROFILE_CLOUD)
public DataSource dataSource() {
    log.debug("Configuring Datasource");
    if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) {
        log.error("Your database connection pool configuration is incorrect! The application" +
                " cannot start. Please check your Spring profile, current profiles are: {}",
                Arrays.toString(env.getActiveProfiles()));

        throw new ApplicationContextException("Database connection pool is not configured correctly");
    }
    HikariConfig config = new HikariConfig();
    if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("jndi"))){
     config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName"));
     if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) {
         config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName"));
         config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName"));
     } else {
         config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url"));
     }
     config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username"));
     config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password"));
     config.setConnectionTimeout(10000);
     config.setMaximumPoolSize(25);
    }else{
    	final JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
        dataSourceLookup.setResourceRef(true);
    	DataSource dataSourceTemp = null;
        try {
            dataSourceTemp = dataSourceLookup.getDataSource(dataSourcePropertyResolver.getProperty("jndi"));
        } catch (DataSourceLookupFailureException e) {
            log.error("DataSource not found.");
        }
        config.setDataSource(dataSourceTemp);
    }

    if (metricRegistry != null) {
        config.setMetricRegistry(metricRegistry);
    }
    return new HikariDataSource(config);
}
 
开发者ID:Cineca,项目名称:OrcidHub,代码行数:43,代码来源:DatabaseConfiguration.java

示例13: dataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
    final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);
    return dsLookup.getDataSource(dataSourceName());
}
 
开发者ID:bartgerard,项目名称:ubrew_v0.1,代码行数:7,代码来源:JndiDataSourceConfig.java

示例14: dataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
	JndiDataSourceLookup lookup = new JndiDataSourceLookup();
	return lookup.getDataSource(jndiDatasource);
}
 
开发者ID:BlueWizardHat,项目名称:2fa-demo,代码行数:6,代码来源:PersistenceJpaConfig.java

示例15: dataSource

import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
 public DataSource dataSource() {
		
JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
   
dsLookup.setResourceRef(true);
     
     return dsLookup.getDataSource(jndiDatasource);
 }
 
开发者ID:mcraken,项目名称:spring-scaffy,代码行数:10,代码来源:SpringJNDIDatasourceConfig.java


注:本文中的org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。