I'm seeing the same problem with DB2 JDBC and JServ. I followed the
JDBC
example given in the book "Java Servlet Programming" by Jason Hunter and
William Crawford, but I keep getting a "SQLException caught : No suitable
driver " error message. This is after I included the CLASSPATH for the DB2
JDBC driver inside JServ. Before that I got an "unable to load : null"
message.
The Snoop Servlet and other servlets like "hello world" all work for me. The
problem seems to come when I try to make a JDBC call to the database. Looks
like it can't load the driver for whatever reason.
example given in the book "Java Servlet Programming" by Jason Hunter and
William Crawford, but I keep getting a "SQLException caught : No suitable
driver " error message. This is after I included the CLASSPATH for the DB2
JDBC driver inside JServ. Before that I got an "unable to load : null"
message.
The Snoop Servlet and other servlets like "hello world" all work for me. The
problem seems to come when I try to make a JDBC call to the database. Looks
like it can't load the driver for whatever reason.
I'm using DB2, Apache 1.3.4 on WinNT.
I've included the code for my servlet. Could the problem lie there ?
Regards,
Pascal Chong
Singapore
============= code begins here ===============
import java.io.* ;
import java.sql.* ;
import javax.servlet.* ;
import javax.servlet.http.* ;
I've included the code for my servlet. Could the problem lie there ?
Regards,
Pascal Chong
Singapore
============= code begins here ===============
import java.io.* ;
import java.sql.* ;
import javax.servlet.* ;
import javax.servlet.http.* ;
public class jdbctest extends HttpServlet {
public void doGet ( HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
Connection db2Connection = null;
Statement stmt = null;
ResultSet rs = null;
Statement stmt = null;
ResultSet rs = null;
String url = "jdbc:db2:sample";
String userid = "db2admin";
String passwd = "db2admin";
String userid = "db2admin";
String passwd = "db2admin";
res.setContentType("text/html");
PrintWriter out = res.getWriter();
PrintWriter out = res.getWriter();
try {
// Load and register the DB2 driver
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
// Get a connection to the database
db2Connection = DriverManager.getConnection(url, userid, passwd);
db2Connection = DriverManager.getConnection(url, userid, passwd);
// Create a statement object
stmt = db2Connection.createStatement();
stmt = db2Connection.createStatement();
// Execute a SQL query, get a Result Set
rs = stmt.executeQuery("SELECT * FROM EMPLOYEE");
rs = stmt.executeQuery("SELECT * FROM EMPLOYEE");
// Display the result set as a list
out.println("<HTML><HEAD><TITLE>Employee List</TITLE></HEAD>");
out.println("<BODY>");
out.println("<HTML><HEAD><TITLE>Employee List</TITLE></HEAD>");
out.println("<BODY>");
while (rs.next())
{
out.println("<BR>" + rs.getString(2) + " " + rs.getString(4));
}
out.println("</BODY></HTML>");
}
catch (ClassNotFoundException e) {
out.println("Couldn't load database driver: " + e.getMessage());
}
catch (SQLException e) {
out.println("SQLException caught : " + e.getMessage());
}
finally {
// Always close the database connection
try {
if (db2Connection != null) db2Connection.close();
}
catch (SQLException ignored) { }
}
out.println("<BR>" + rs.getString(2) + " " + rs.getString(4));
}
out.println("</BODY></HTML>");
}
catch (ClassNotFoundException e) {
out.println("Couldn't load database driver: " + e.getMessage());
}
catch (SQLException e) {
out.println("SQLException caught : " + e.getMessage());
}
finally {
// Always close the database connection
try {
if (db2Connection != null) db2Connection.close();
}
catch (SQLException ignored) { }
}
=========================================================
}
}
-----Original Message-----
From: Eduardo Mardell <[EMAIL PROTECTED]>
To: Java Apache Users <[EMAIL PROTECTED]>
Date: Thursday, June 03, 1999 11:35 PM
Subject: Re: Oracle JDBC and JServ
>Thanks for the comments on permissions....have a hope there for a minute
but
>all are readable and executable
>where required to world.
>
>Update...Just tried the SnoopServlet and that doesn't work from the jdk
>examples although
>our test servlets do work ...in the same directory ? Does this enlighten
>anyone ?
>
>Ed.
}
}
-----Original Message-----
From: Eduardo Mardell <[EMAIL PROTECTED]>
To: Java Apache Users <[EMAIL PROTECTED]>
Date: Thursday, June 03, 1999 11:35 PM
Subject: Re: Oracle JDBC and JServ
>Thanks for the comments on permissions....have a hope there for a minute
but
>all are readable and executable
>where required to world.
>
>Update...Just tried the SnoopServlet and that doesn't work from the jdk
>examples although
>our test servlets do work ...in the same directory ? Does this enlighten
>anyone ?
>
>Ed.
=================================================================
