本文整理汇总了Java中org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.setResourceRef方法的典型用法代码示例。如果您正苦于以下问题:Java JndiDataSourceLookup.setResourceRef方法的具体用法?Java JndiDataSourceLookup.setResourceRef怎么用?Java JndiDataSourceLookup.setResourceRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup
的用法示例。
在下文中一共展示了JndiDataSourceLookup.setResourceRef方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
示例7: 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);
}
示例8: 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);
}
示例9: 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());
}
示例10: dataSource
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
dsLookup.setResourceRef(true);
return dsLookup.getDataSource(jndiDatasource);
}