Hi, I am using Linux 2.2, Apache 1.3.9 with JServ
1.0, and Blackdown Java 1.2.. I am trying to write a Servlet to interect with a
MySQL 3.22... I have the mm.mysql JDBC driver... A small application to test the
database conectivity works when I run it with the normal java JTest command...
but when I put the database code into the servlet it does nothing... the code
that throws the exception looks something like:
try
{ // Workaround for broken Java implementations Class.forName("org.gjt.mm.mysql.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/radon?user=root&password=agent1337"); Statement Stmt = con.createStatement(); ResultSet RS = Stmt.executeQuery("SELECT * from table"); while (RS.next())
{ out.println(RS.getString(1)); out.println(RS.getString(2)); } RS.close(); Stmt.close(); con.close(); } catch(Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); out.println("<pre>"); out.print(sw.toString()); out.println("</pre>"); } Now when I run this code I get in the
web-browser:
java.lang.ClassNotFoundException:
org.gjt.mm.mysql.Driver
at org.apache.java.lang.AdaptiveClassLoader.loadClass(Compiled Code) at java.lang.ClassLoader.loadClass(Compiled Code) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Compiled Code) at JSTest.doGet(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at org.apache.jserv.JServConnection.processRequest(Compiled Code) at org.apache.jserv.JServConnection.run(Compiled Code) at java.lang.Thread.run(Compiled Code) This code is almost literaly copy/pasted from the mm.mysql
driver examples...
my jserv.properties file looks like:
wrapper.class=org.apache.jserv.JServ
wrapper.class=org.gjt.mm.mysql.Driver wrapper.classpath=/usr/src/ApacheJServ-1.0/src/java/ApacheJServ.jar
wrapper.classpath=/usr/local/JSDK2.0/lib/jsdk.jar wrapper.classpath=/usr/local/mm.mysql.jdbc-1.2b/mysql_comp.jar # I tried with either one of these statments... both... and noone... and its the same result wrapper.classpath=/usr/local/mm.mysql.jdbc-1.2b/mysql_uncomp.jar I don't get why it doesn't work... it fails to load the
driver... the driver works and loads when I run it from a normal application but
not from jserv... realy weird... the zone is the same as the regular root zone
that was created when I installed JServ... and the file I am testing I put in
the example directory aloong with the hello.class file (I know its pretty ghetto
but I haven't gotten around to organizing the directory structure.... and this
servlet is only a database test)
Can someone please help me with this problem.... I read the
FAQ-O-Matic... (for hours I might add) and I couldn't find anything that
worked... I also read a bunch of documents on servletcentral and some other
sites pointed to by the jserv web-site... but still no luck... I am sure its
something so simple that I can't see it...
Thaks in advance
Stou Sandalski
|
- Re: JDBC Driver problem with JServ 1.0 Stou Sandalski
- Re: JDBC Driver problem with JServ 1.0 Mohamed Riaz