I have an existing spring framework based web application. I want to use JNDI on Tomcat 6 and Oracle server for it. Please explain a simple step by step procedure for the same.
Asked
Active
Viewed 608 times
2 Answers
1
Please follow these steps:
- Add the following code in the tag
<GlobalNamingResources>
in the following file:
apache-tomcat-6.0.37/conf/server.xml
<Resource name="jdbc/dbName" auth="Container" type="javax.sql.DataSource"
username="xyz" password="abcd"
url="jdbc:url"
driverClassName="oracle.jdbc.driver.OracleDriver"
initialSize="5" maxWait="5000"
maxActive="120" maxIdle="5"
poolPreparedStatements="true"/>
- Add the following code in the tag
<Context>
in the following file
apache-tomcat-6.0.37/conf/context.xml
<ResourceLink name="jdbc/dbName" global="jdbc/dbName" type="javax.sql.DataSource"/>
- Add the following code in the file
applicationContext.xml
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/dbName" expected-type="javax.sql.DataSource" />
- Make sure the
<beans:xmlns
tag in theapplicationContext.xml
has the following data:
xmlns:jee="http://www.springframework.org/schema/jee"
and these schemas in their xsi:schemaLocation
:
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
- Ensure that
ojdbc14.jar
is present in the folder:
apache-tomcat-6.0.37\lib
- Remove the previous database connection parameters defined in your application(property files/dataSource beans defined in applicationContext.xml).
That should be enough.

Aniruddha
- 308
- 2
- 11
0
This was a great knowledge, Can you please also share how to condigure JNDI for external LDAP datasource?
The database JNDI worked finne for me after following your steps. You can get more details in below link. External LDAP JNDI connectivity using Tomcat
Thanks Anny
-
sorry i have no idea about LDAP configuration. I will try to find out though. – Aniruddha Oct 08 '14 at 05:48