本文整理汇总了Java中org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup类的典型用法代码示例。如果您正苦于以下问题:Java JndiDataSourceLookup类的具体用法?Java JndiDataSourceLookup怎么用?Java JndiDataSourceLookup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JndiDataSourceLookup类属于org.springframework.jdbc.datasource.lookup包,在下文中一共展示了JndiDataSourceLookup类的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: testMetaInfCase
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testMetaInfCase() throws Exception {
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/META-INF/persistence.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertNotNull(info);
assertEquals(1, info.length);
assertEquals("OrderManagement", info[0].getPersistenceUnitName());
assertEquals(2, info[0].getJarFileUrls().size());
assertEquals(new ClassPathResource("order.jar").getURL(), info[0].getJarFileUrls().get(0));
assertEquals(new ClassPathResource("order-supplemental.jar").getURL(), info[0].getJarFileUrls().get(1));
assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses());
}
示例3: testExample2
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testExample2() throws Exception {
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/persistence-example2.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertNotNull(info);
assertEquals(1, info.length);
assertEquals("OrderManagement2", info[0].getPersistenceUnitName());
assertEquals(1, info[0].getMappingFileNames().size());
assertEquals("mappings.xml", info[0].getMappingFileNames().get(0));
assertEquals(0, info[0].getProperties().keySet().size());
assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses());
}
示例4: testExample3
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testExample3() throws Exception {
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/persistence-example3.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertNotNull(info);
assertEquals(1, info.length);
assertEquals("OrderManagement3", info[0].getPersistenceUnitName());
assertEquals(2, info[0].getJarFileUrls().size());
assertEquals(new ClassPathResource("order.jar").getURL(), info[0].getJarFileUrls().get(0));
assertEquals(new ClassPathResource("order-supplemental.jar").getURL(), info[0].getJarFileUrls().get(1));
assertEquals(0, info[0].getProperties().keySet().size());
assertNull(info[0].getJtaDataSource());
assertNull(info[0].getNonJtaDataSource());
assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses());
}
示例5: testExample5
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testExample5() throws Exception {
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/persistence-example5.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertNotNull(info);
assertEquals(1, info.length);
assertEquals("OrderManagement5", info[0].getPersistenceUnitName());
assertEquals(2, info[0].getMappingFileNames().size());
assertEquals("order1.xml", info[0].getMappingFileNames().get(0));
assertEquals("order2.xml", info[0].getMappingFileNames().get(1));
assertEquals(2, info[0].getJarFileUrls().size());
assertEquals(new ClassPathResource("order.jar").getURL(), info[0].getJarFileUrls().get(0));
assertEquals(new ClassPathResource("order-supplemental.jar").getURL(), info[0].getJarFileUrls().get(1));
assertEquals("com.acme.AcmePersistence", info[0].getPersistenceProviderClassName());
assertEquals(0, info[0].getProperties().keySet().size());
assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses());
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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;
}
示例12: getJndiDataSource
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
protected DataSource getJndiDataSource() {
if (StringUtil.isEmpty(this.propertiesConfig.dataSourceJndiName())) {
throw new IllegalStateException("'dataSourceJndiName' property is required");
}
try {
return new JndiDataSourceLookup()
.getDataSource(this.propertiesConfig.dataSourceJndiName());
} catch (Exception e) {
throw new IllegalStateException(
"failed to look up JNDI DataSource for name=" + this.propertiesConfig.dataSourceJndiName(), e);
}
}
示例13: testExample1
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testExample1() throws Exception {
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/persistence-example1.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertNotNull(info);
assertEquals(1, info.length);
assertEquals("OrderManagement", info[0].getPersistenceUnitName());
assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses());
}
示例14: testExample4
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testExample4() throws Exception {
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
DataSource ds = new DriverManagerDataSource();
builder.bind("java:comp/env/jdbc/MyDB", ds);
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/persistence-example4.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertNotNull(info);
assertEquals(1, info.length);
assertEquals("OrderManagement4", info[0].getPersistenceUnitName());
assertEquals(1, info[0].getMappingFileNames().size());
assertEquals("order-mappings.xml", info[0].getMappingFileNames().get(0));
assertEquals(3, info[0].getManagedClassNames().size());
assertEquals("com.acme.Order", info[0].getManagedClassNames().get(0));
assertEquals("com.acme.Customer", info[0].getManagedClassNames().get(1));
assertEquals("com.acme.Item", info[0].getManagedClassNames().get(2));
assertTrue("Exclude unlisted should be true when no value.", info[0].excludeUnlistedClasses());
assertSame(PersistenceUnitTransactionType.RESOURCE_LOCAL, info[0].getTransactionType());
assertEquals(0, info[0].getProperties().keySet().size());
builder.clear();
}
示例15: testExample6
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; //导入依赖的package包/类
@Test
public void testExample6() throws Exception {
PersistenceUnitReader reader = new PersistenceUnitReader(
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
String resource = "/org/springframework/orm/jpa/persistence-example6.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertEquals(1, info.length);
assertEquals("pu", info[0].getPersistenceUnitName());
assertEquals(0, info[0].getProperties().keySet().size());
assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses());
}