hi all,
i am new to use servlet, however, i wrote the program below but the
error shown as subject.
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InventoryServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String id = req.getParameter("id");
PrintWriter out = res.getWriter();
try {
// create a connection
Class.forName("com.pointbase.jdbc.jdbcUniversalDriver").newInstance();
String url = "jdbc:pointbase:server://localhost/mt811";
String uid = "pbpublic";
String pwd = "pbpublic";
Connection Con = DriverManager.getConnection(url, uid, pwd);
Statement stm = Con.createStatement();
String sql = "SELECT * FROM Inventory";
// get the customer info
ResultSet result = stm.executeQuery(sql);
out.println("<html><head><title>tsting</title></head></html>");
out.println("<h2>database</h2>");
while (result.next()) {
// out.println(result.getString("Name"));
// out.println(result.getInt("Quantity"));
out.print(result.getInt("Quantity"));
out.println(result.getString("InventoryID"));
out.println(result.getString("Name"));
}
// Clean up
result.close();
stm.close();
Con.close();
} catch (Exception e) {
out.println(e.toString());}
}
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws IOException, ServletException {
doGet(request, response);
}
}
the same driver , login, passwd can be used in another program and
successfully.
pls advise.
paul
theath - 15 Jul 2005 15:51 GMT
where is the jdbc jar relative to your app? on your other program, was
it bundled in there with it, or is your jar in your appserver's lib
directory?
paul - 16 Jul 2005 14:29 GMT
pbclient.jar under the pointbase directory and already set it in my
classpath.
same server ( i use tomcat) , same jdk.
John Currier - 18 Jul 2005 03:07 GMT
As theath indicated the exception is fairly descriptive in what's
wrong: the classloader isn't able to find the class you're trying to
load. Have you compared the configurations of the two Tomcat servers?
One of them points to an appropriate pbclient.jar...one doesn't.
John
http://schemaspy.sourceforge.net
steve - 31 Jul 2005 02:17 GMT
> hi all,
>
[quoted text clipped - 56 lines]
>
> paul
sloppy very sloppy !!
} finally{
closeports( Con,result, stm);
}
}
public static void closeports(
.........) {
if (.. != null) {
try {
...close();
} catch (Exception ex) {
out.println(ex.toString());
}
}
if (... != null) {
try {
...close();
} catch (Exception ex) {
out.println(ex.toString());
}
}
if (.....!= null) {
try {
..close();
} catch (Exception ex) {
out.println(ex.toString());
}
}
}