This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


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
Author

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

Surender Busireddy
Greenhorn

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!="")
{
try{

//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);
stmt.setString(1,username);
stmt.setString(2,password);
rs = stmt.executeQuery();

boolean flag = false;
while(rs.next() && !flag){

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

}catch(Exception e){

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

%>





Thanks in advance..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

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: http://aspose.com/file-tools
 
subject: oracle.jdbc.driver.OracleDriver cannot be resolved to a type