Из контейнерного источника данных JNDI

Используйте платформу журналирования, которая реализует некоторую форму шаблон NDC , как Log4J.

15
задан Pascal Thivent 23 October 2009 в 20:08
поделиться

2 ответа

Why are you using JNDI for this? It's not that it's a bad solution if you have a provider but there are alternatives such as dependency injection (IoC: via Spring or Guice).

The Spring JDBC data access is described here. The great thing is that you can use Spring to inject a DataSource into your code:

<bean class="com.my.Persister">
    <property name="dataSource" ref="dataSource" />
</bean>

The data source can be defined using a JNDI-lookup:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/MyDataSource" /> 

In a test environment, you could inject the data source directly:

<bean id="dataSource" class="apache.db.PoolingDataSource">
    <!-- config goes here -->
</bean>
10
ответ дан 1 December 2019 в 04:01
поделиться

Эти ссылки довольно старые, но могут помочь использовать jnpserver (поставщик службы имен JBoss):

4
ответ дан 1 December 2019 в 04:01
поделиться
Другие вопросы по тегам:

Похожие вопросы: