Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Surender Busireddy
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18324
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic