This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Tomcat and the fly likes oracle.jdbc.driver.OracleDriver cannot be resolved to a type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "oracle.jdbc.driver.OracleDriver cannot be resolved to a type" Watch "oracle.jdbc.driver.OracleDriver cannot be resolved to a type" New topic

oracle.jdbc.driver.OracleDriver cannot be resolved to a type

Surender Busireddy

Joined: Apr 12, 2012
Posts: 1
Hi friends,

Im getting following error when I ran my jsp code in tomcat.

"oracle.jdbc.driver.OracleDriver cannot be resolved to a type"

I have added ojdbc14.jar in my lib folder. Give me some suggestions to overcome this.

This is my JSP code.

<%@page import ="java.sql.*"%>
String username;
String password;
String tableName = "BUYSM_USERS";
Connection connection;
ResultSet rs;

username = request.getParameter("username");
password = request.getParameter("password");

if(username!="" && password!="")

//register Driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//get Connection
connection = DriverManager.getConnection("jdbc: oracle:thin:@url: DB","user","pwd");

String query = "Select username,password from "+tableName+" where username = ? and password = ?";

PreparedStatement stmt = connection.prepareStatement(query);
rs = stmt.executeQuery();

boolean flag = false;
while( && !flag){

if(username.equals(rs.getString(1)) && password.equals(rs.getString(2))){
flag = true;
//upload page
//same page
out.println("not found");

}catch(Exception e){

out.println("Enter username & password");


Thanks in advance..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16473

It doesn't much matter. People will come along and tell you not to do it this way.

J2EE can be employed cheap-quick-and-dirty a la Microsoft ASP, but it's not considered good practice. J2EE has the advantage that it's secure, performant, and scalable, but to obtain all those benefits, you need to adopt a more rigorous application architecture. There's no shortage of books on the subject.

A professional-grade J2EE webapp wouldn't use code snippets on a JSP, it would employ Separation of Concerns to put the logic in a separate javabean (.java) file. Likewise, it wouldn't attempt to obtain the Oracle driver directly by name. And finally, it wouldn't reference Oracle directly in the webap at all. It would use a server-defined database connection pool.

As a purely academic exercise, the Oracle driver would have to be located in the application WAR's WEB-INF/lib directory for this JSP to see it (NOT the TOMCAT/lib directory). Also, I have doubts about using "registerDriver". The old way simply used Class.forName(), and I'm pretty sure that these days, the driver jar is self-registering.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: oracle.jdbc.driver.OracleDriver cannot be resolved to a type