My Current project backend code is filled with these jndi lookups just to retrieve datasource
InitialContext ic = new InitialContext();
Datasource ds = (DataSource) ic.lookup("Build Datasource");
I'm wondering what is the easiest way to instead use Spring and get the dataSource object.
I tried this and it doesn't seem to work
<jee:jndi-lookup id="dataSource" jndi-name="Build Datasource"/>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
(is above approach correct way to do and not working only because my local tomcat JNDI is messed up?)
What is the best way to avoid using manual lookups all over the code and just get the datasource magically from Spring?
Aucun commentaire:
Enregistrer un commentaire