| Author |
Datasource configuration in Tomcat
|
Srikant Venkata
Greenhorn
Joined: Jun 16, 2011
Posts: 19
|
|
Hi All,
I am trying to configure the Datasource in Tomcat 6.0 using a context.xml file.
I am using Oracle 10g as Database.
I have placed the below changes inside /META-INF/context.xml
<Context>
<Resource auth="Container" name="jdbc/loginApp" type="javax.sql.DataSource"
description="Login Application" driverClassName="oracle.jdbc.OracleDriver"
maxActive="100" maxIdle="10" maxWait="10000" password="l0g1napp"
url="jdbc racle:thin:@localhost:1521:xe" username="loginapp" />
</Context>
In My application, I am trying to do lookup using the below code for lookup name as "loginApp".
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/" + streamName);
But, When I run the application, I get the below error
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at com.myapp.Utilities.Datastreams.getConnection(Datastreams.java:16)
at com.myapp.Controller.LoginController.ValidateLogin(LoginController.java:68)
at com.myapp.Controller.LoginController.doPost(LoginController.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
What more configurations should I follow such that my application picks up the context.xml. Should I add any reference to context.xml in my Web.xml?
-Regards
Srikant Mantha
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You need to add the Oracle driver JAR file in either your application's lib folder, or in Tomcat's lib folder.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Srikant Venkata
Greenhorn
Joined: Jun 16, 2011
Posts: 19
|
|
Thanks, It works now when I added the jar file in Tomcat Server Libs. Earlier I had added only to the Application's Build path.
-Regards
Srikant Mantha
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
 |
|
|
subject: Datasource configuration in Tomcat
|
|
|