I used Oracle 8.1.7 database, j2sdk1.4.1_03, and I have sequentially tested the following drivers : classes111.zip, classes12.zip, and ojdbc14.jar, but still got the same error message as it runs below. Please help!
******************************
before Unable to load driver.
--------------------------
SQLException: No suitable driver SQLState: 08001 VendorError: 0
We are in business
****************************
here is my program:
****************************
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
public
class someclass extends HttpServlet {
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
ServletOutputStream out = res.getOutputStream();
out.println("<html>");
out.println("<head><title>byName</title></head>");
out.println("<body>");
try {
out.println("before");
Class.forName("oracle.jdbc.driver.OracleDriver");
out.println("after");
}
catch (Exception E) {
out.println("Unable to load driver.");
E.printStackTrace();
}
out.println("<br><hr>");
try {
Connection conn = null;
conn = DriverManager.getConnection("jdbc
racle:thin:@host:1521
atabase", "user", "pwd");
Statement Stmt = conn.createStatement();
ResultSet RS = Stmt.executeQuery("SELECT * from sometable");
while (RS.next()) {
out.println(RS.getString(1));
}
// Clean up after ourselves
RS.close();
Stmt.close();
conn.close();
}
catch (SQLException E) {
out.println("SQLException: " + E.getMessage());
out.println("SQLState: " + E.getSQLState());
out.println("VendorError: " + E.getErrorCode());
}
out.println("<h1>We are in business</h1>");
out.println("</body></html>");
}
public
String getServletInfo() {
return "Get infor from
servlet and send it back";
}
}
[ August 08, 2003: Message edited by: long silver ]