Dears,
i face same this problem ,and the solution ware as the following:
1- write xml file which contains the
JDBC Connection attributes:
note: the file name should be same webapplication name, and it's case sensitive.
XML file : Test.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/Test">
<Resource name="jdbc/TestDB" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:testdb"
username="user123" password="password123" maxActive="20" maxIdle="10"
maxWait="-1"/>
</Context>
2- put the file name in the \Tomcat 6.0\conf\Catalina\localhost directory.
3- add the following tags in the web.xml:
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4- use the lookup method to get the DataSource as :
DataSource ds = (DataSource)new InitialContext().lookup( "java:comp/env/jdbc/TestDB" );
note: the names are case sensitive
Regards.