Here’s a guide to show you how to configure JNDI datasource in ColdFusion 10.
1. Get the JDBC Driver
The JDBC Driver needs to be placed in ColdFusion10/cfusion/runtime/lib folder.
2. context.xml configuration
Add a resource block before the closing tag (</Context>) in the context.xml present at ColdFusion10/cfusion/runtime/conf , which defines database connection detail :
<Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource"
maxActive="50" maxIdle="30" maxWait="10000"
username="username" password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"/>
For more information on the attributes please refer to http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html.For setting isolation level use the defaultTransactionIsolation attribute.
3. web.xml configuration
In the web.xml present at ColdFusion10/cfusion/wwwroot/WEB-INF , add the following just before the closing tag (</web-app>):
<resource-ref>
<description>MySQL Datasource example</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4. Add ColdFusion DataSource through Administrator
After saving the configuration files restart the ColdFusion server.Log in to ColdFusion Administrator and navigate to Data & Services > Data Sources and add a new Data Source by selecting J2EE Data Source(JNDI) in the driver drop down.For more details on this refer http://help.adobe.com/en_US/ColdFusion/10.0/Admin/WSc3ff6d0ea77859461172e0811cbf364104-7fdf.html .
Hope you found this useful.Write in to us if you have any issues with the Tomcat specific configuration.
-Asha