How to use jndi datasource provided by tomcat in spring?



How to use jndi datasource provided by tomcat in spring?..

Answer / Ankur Kesarwani

To use a JNDI data source provided by Tomcat in Spring, you should first create and configure the data source within your Tomcat `server.xml` or `context.xml` file. Then, in your Spring application context file (usually an XML or Java-based configuration class), define the data source as a bean using JNDI lookup:

<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/MyDataSource"/>
</bean>

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Tomcat Interview Questions

On which port does apache work?

1 Answers  


How do I know what port tomcat is using?

1 Answers  


I have a "webb app" in Tomcat that serves only HTML, and I'd like to make the path component of the URL case- insensitive. So if the client navigates to http://<domain.host>/Pics or http://<domain.host>/pics or http://<domain.host>/PIcs they'll get the same resource.

1 Answers  


How can we specify system properties in tomcat configuration on startup?

1 Answers  


What is a mod_evasive module?

1 Answers  


what are the connectors used in tomcat?

1 Answers  


Where is apache net server situated in information heart location?

1 Answers  


How do you deploy ejb in tomee?

1 Answers  


What is the difference between worker and prefork mpm?

1 Answers  


Is tomcat a jvm?

1 Answers  


What is tomcat and how it works?

1 Answers  


How do I use datasources with tomcat?

1 Answers  


Categories