List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:September 21 1999 5:13pm
Subject:Re: SERVLETS - JDBC - MYSQL - org.gjt.mm.mysql.driver
View as plain text  
Luis Cláudio dos Santos wrote:
> 
> Hello!
> I'm using Linux 5.2 , Apache 1.3.6, MySQL and MM MySQL.JDBC.Driver .
> My Servlets works very well and my JDBC Java programs too!
> But, when I try using servlets/jdbc middle tier to access my database, I have got
> this error message:
> 
> in /usr/local/apache/logs/error_log
> 
> ******************
> java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
>         at
> org.apache.java.lang.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:437)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java)
>         at DBServlet.doGet(DBServlet.java:33)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
>         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:335)
>         at org.apache.jserv.JServConnection.run(JServConnection.java:197)
>         at java.lang.Thread.run(Thread.java)
> [Sun Sep 19 10:15:39 1999] [error] [client 161.24.76.54] Premature end of script
> headers: /servlets/DBServlet
> ******************
> 
> in /usr/local/ApacheJServ-1.0/conf/jserv.log
> 
> *******************
> [19/09/1999 10:15:39:238] (EMERGENCY) ajp11: cannot scan servlet headers
> [19/09/1999 10:15:39:238] (ERROR) an error returned handling request via protocol
> "ajpv11"
> *******************
> 
> 
> Can you help me!
> It's very important to me...
> Where can I find samples of servlets database access with mm jdbc driver?
> My servlet program is atached:
> 
> 
>            
> ----------------------------------------------------------------------------------------->
> import org.gjt.mm.mysql.*;
> 
> import org.gjt.mm.mysql.Connection;
> import org.gjt.mm.mysql.Statement;
> import org.gjt.mm.mysql.Driver;
> import org.gjt.mm.mysql.ResultSet;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> import java.sql.*;
> import java.net.*;
> import java.io.*;
> 
> public class DBServlet extends HttpServlet {
> 
> Connection c;
> 
> public void doGet(HttpServletRequest request, HttpServletResponse response)  throws
> ServletException, IOException{
> 
>         response.setContentType("text/html");
>         PrintWriter out = response.getWriter();
> 
>         out.println("<HTML>");
>         out.println("<BODY bgcolor=\"#FFFFFF\">");
>         out.println("<H1>DataBase Access... </H1><HR>");
> 
> 
>          //Establish database connection
>         try{
>              Class.forName ("org.gjt.mm.mysql.Driver");
>              c = (Connection)
> DriverManager.getConnection("jdbc:mysql://161.24.76.54:3306/registro","user","xxxx");
>          } catch (Exception e) {
>              e.printStackTrace();
>              System.exit(1);
>           }
> 
>     /*   try{
>                        //Code to write to database
>                             Statement stmt = (Statement) c.createStatement();
> 
>                        //Code to read from database
>                             ResultSet results =  (ResultSet)
> stmt.executeQuery("SELECT nome FROM pessoa ");
>                             while(results.next()){
>                               String s = results.getString("nome");
>                               out.println("<STRONG>Text from
> database:</STRONG>");
>                               out.println(s);
>                             }
>            stmt.close();
>            }
>            catch(java.sql.SQLException e){
>               System.out.println(e.toString());
>            }
> 
>     */
>            out.println("</BODY></HTML>");
>            out.close();
> 
> }//de doGET
> }//de DBServlet

Hi Luis

1) Don't send HTML eMails to a list.
2) This is definitely a question for the java <-> mysql mailing list:
   <mailto:java@stripped>

3) Never import the driver classes. The driver is used via the java.sql.DriverManager
class.
4) You should load the driver only once! So the "Class.forName" should go to the init()
method.
5) I assume you use the Apache JServ servlet engine.
Which version do you use?
6) Is the mysql.jar file (or the class files in it) in your servlet engine CLASSPATH?
7) Which version of mm do you use?

Tschau
Christian

Thread
SERVLETS - JDBC - MYSQL - org.gjt.mm.mysql.driverLuis Cláudio dos Santos19 Sep
  • Re: SERVLETS - JDBC - MYSQL - org.gjt.mm.mysql.driverChristian Mack21 Sep