How to use JNDI DataSource provided by Tomcat in Spring?
If using Spring’s XML schema based configuration, setup in the Spring context like this: <beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:jee=”http://www.springframework.org/schema/jee” xsi:schemaLocation=” http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd”> … <jee:jndi-lookup id=”dbDataSource” jndi-name=”jdbc/DatabaseName” expected-type=”javax.sql.DataSource” /> Alternatively, setup using simple bean configuration like this: <bean id=”DatabaseName” class=”org.springframework.jndi.JndiObjectFactoryBean”> <property name=”jndiName” value=”java:comp/env/jdbc/DatabaseName”/> </bean> You can declare the JNDI resource in tomcat’s server.xml using something … Read more