----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
Hello all !
I know this question was answered before and it was posted on the
FAQ-o-matic. I know because I printed it out and have it right next to
me. However, the answer doesn't seem to work ...
The problem :
1. I'm writing a servlet that connects to DB2 and retrieves all the data
from a table EMPLOYEE.
2. My configuration is :
Apache JServ 1.0 Final
Apache 1.3.9
JDK 117v3
DB2 Universal Database v6.1 Enterprise Edition
3. I can compile the servlet without errors, but when I try to access
it, I get an error which says :
Error occurred : COM.ibm.db2.jdbc.net.DB2Driver
4. According to the FAQ-o-matic document, I am able to compile the
servlet without errors because DB2's driver is in my system CLASSPATH
(which it is !), but unable to access the servlet because Apache JServ
reads and loads the CLASSPATH from another source : jserv.properties
5. OK. So, I put the following line inside the jserv.properties file :
wrapper.classpath=/opt/jdk117_v3/jdbc/db2java.zip
6. I rebooted the system, you know, just to be sure.
7. Tried again, and same error again.
8. OK. Here's my source code, if you're interested :
//DB2ServletTest.java - Testing servlet access to DB2
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DB2ServletTest extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try {
//Load and register the DB2 Driver
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
//Get a connection to the database con =
DriverManager.getConnection("jdbc:db2://localhost:6789/sample","db2inst1","ibmdb2");
//Create a statement object
stmt = con.createStatement();
//Execute an SQL query, get a ResultSet
rs = stmt.executeQuery("SELECT FIRSTNME, LASTNAME FROM
EMPLOYEE");
//Display the result set as a list
out.println("<HTML><HEAD><TITLE>Employee
List</TITLE></HEAD>");
out.println("<BODY>");
out.println("<UL>");
//rs.next() returns false when end of list
while(rs.next()) {
out.println("<LI>" + rs.getString("firstnme") + "
" + rs.getString("lastname"));
}
out.println("</UL>");
out.println("</BODY></HTML>");
}
catch(ClassNotFoundException e) {
out.println("");
out.println("Can't load the f**king driver. Where is
it ?");
out.println("Error occurred : " + e.getMessage());
}
catch (SQLException e) {
out.println("SQLException caught: " + e.getMessage());
}
finally {
//Always close the database connection
try {
if (con != null) con.close();
}
catch (SQLException ignored) { }
} //end finally
}
}//:~
============
Thanks In Advance and Regards,
Pascal Chong
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]