本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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");
}
}
示例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");
}
示例10: bookManagerDataSource
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource bookManagerDataSource() {
JndiDataSourceLookup lookup = new JndiDataSourceLookup();
return lookup.getDataSource("jdbc/bookManager");
}
示例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);
}
示例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);
}
示例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());
}
示例14: dataSource
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
JndiDataSourceLookup lookup = new JndiDataSourceLookup();
return lookup.getDataSource(jndiDatasource);
}
示例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);
}