in Spring by
Q:

How to use Tomcat JNDI DataSource in Spring Web Application?

1 Answer

0 votes
by
For using servlet container configured JNDI DataSource, we need to configure it in the spring bean configuration file and then inject it to spring beans as dependencies. Then we can use it with JdbcTemplate to perform database operations.

Sample configuration would be:

<beans:bean id="dbDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

    <beans:property name="jndiName" value="java:comp/env/jdbc/MyLocalDB"/>

</beans:bean>

For complete example, please refer Spring Tomcat JNDI Example.
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

0 votes
asked Jul 28, 2020 in Spring by sharadyadav1986
0 votes
asked Jul 28, 2020 in Spring by sharadyadav1986
0 votes
asked Jul 26, 2020 in Spring by SakshiSharma
0 votes
asked Jul 28, 2020 in Spring by Robindeniel
0 votes
asked Dec 1, 2019 in DevOps by SakshiSharma
...