org.gjt.mm.musql.Driver Error

org.gjt.mm.musql.Driver Error

Post by Alexander Emmanue » Sun, 13 Apr 2003 11:01:15



Hi all,

I am new in using Java servlets, mysql and JDBC and when I am tyrying to
conect to my database i get the following error:
        SQL error in doGet: com.mm.mysql.Driver

Could you please tell me a solution to this problem and why it is appears?

Thanks you

Alex

 
 
 

org.gjt.mm.musql.Driver Error

Post by albertogor » Sun, 13 Apr 2003 17:25:17




Quote:> Hi all,

> I am new in using Java servlets, mysql and JDBC and when I am tyrying to
> conect to my database i get the following error:
>         SQL error in doGet: com.mm.mysql.Driver

> Could you please tell me a solution to this problem and why it is appears?

> Thanks you

> Alex

are you using Tomcat? where did you put the driver classes?
Howare you connecting to database?

 
 
 

org.gjt.mm.musql.Driver Error

Post by Darren Daviso » Sun, 13 Apr 2003 18:59:40



> Hi all,

> I am new in using Java servlets, mysql and JDBC and when I am tyrying to
> conect to my database i get the following error:
>         SQL error in doGet: com.mm.mysql.Driver

> Could you please tell me a solution to this problem and why it is appears?

> Thanks you

> Alex

well your subject says org.gjt.mm.mysql.Driver (the old one) and the body
says com.mm.mysql.Driver, which looks like you're trying to use the new
one.  If this is the case, use the right driver name: com.mysql.jdbc.Driver

--

davison|uk.net      www.davison.uk.net/key.jsp

 
 
 

org.gjt.mm.musql.Driver Error

Post by Alexander Emmanue » Sun, 13 Apr 2003 23:16:23


I am using tomcat 4.1.18 and I put the class driver inside tomcat4/lib
subdirectory.
In order to connect to the database I am using mm.mysql-2.0.13.
The way I am trying to connect is the following:
        try
           {
              Class.forName("org.gjt.mm.mysql.Driver");
              Connection con = DriverManager.getConnection(url, client,
alex);

              Statement statement = con.createStatement();




> > Hi all,

> > I am new in using Java servlets, mysql and JDBC and when I am tyrying to
> > conect to my database i get the following error:
> >         SQL error in doGet: com.mm.mysql.Driver

> > Could you please tell me a solution to this problem and why it is
appears?

> > Thanks you

> > Alex

> are you using Tomcat? where did you put the driver classes?
> Howare you connecting to database?

 
 
 

org.gjt.mm.musql.Driver Error

Post by Alexander Emmanue » Sun, 13 Apr 2003 23:20:02


Sorry it was my fault. I use both drivers but i post the wrong error with my
subject. Anyway it didn't work with both drivers.


> > Hi all,

> > I am new in using Java servlets, mysql and JDBC and when I am tyrying to
> > conect to my database i get the following error:
> >         SQL error in doGet: com.mm.mysql.Driver

> > Could you please tell me a solution to this problem and why it is
appears?

> > Thanks you

> > Alex

> well your subject says org.gjt.mm.mysql.Driver (the old one) and the body
> says com.mm.mysql.Driver, which looks like you're trying to use the new
> one.  If this is the case, use the right driver name:

com.mysql.jdbc.Driver

- Show quoted text -

> --

> davison|uk.net      www.davison.uk.net/key.jsp

 
 
 

org.gjt.mm.musql.Driver Error

Post by albertogor » Mon, 14 Apr 2003 02:58:31




> I am using tomcat 4.1.18 and I put the class driver inside tomcat4/lib
> subdirectory.
> In order to connect to the database I am using mm.mysql-2.0.13.
> The way I am trying to connect is the following:
>         try
>            {
>               Class.forName("org.gjt.mm.mysql.Driver");
>               Connection con = DriverManager.getConnection(url, client,
> alex);

>               Statement statement = con.createStatement();





> > > Hi all,

> > > I am new in using Java servlets, mysql and JDBC and when I am tyrying
to
> > > conect to my database i get the following error:
> > >         SQL error in doGet: com.mm.mysql.Driver

> > > Could you please tell me a solution to this problem and why it is
> appears?

> > > Thanks you

> > > Alex

I don't know.
Are you sure about the username and passwrod?
Are you sure mysql is working, and is listening for connection?
Did you put the whole jar file driver in the lib directory?

Alberto.

 
 
 

org.gjt.mm.musql.Driver Error

Post by Alexander Emmanue » Mon, 14 Apr 2003 04:11:48


Thank you for your replies

About the password and the username I 'm sure.
Also mysql is working fine. I am doing the same things with CGI scripts for
the same databse and everything is working fine. So I believe is not the
problem with the database that I create.
Could you please tell me a way of how I must set the Classpath and the path
in order to check if I am doing with these something wrong?

Thank you again

Alex

Quote:> I don't know.
> Are you sure about the username and passwrod?
> Are you sure mysql is working, and is listening for connection?
> Did you put the whole jar file driver in the lib directory?

> Alberto.

 
 
 

org.gjt.mm.musql.Driver Error

Post by albertogor » Mon, 14 Apr 2003 04:35:30




Quote:> Thank you for your replies

> About the password and the username I 'm sure.
> Also mysql is working fine. I am doing the same things with CGI scripts
for
> the same databse and everything is working fine. So I believe is not the
> problem with the database that I create.
> Could you please tell me a way of how I must set the Classpath and the
path
> in order to check if I am doing with these something wrong?

> Thank you again

Ok.
I don't know the directory structure of your version of tomcat. I don't have
a lib directory after CATALINA_HOME. Anyway i put drivers in common/lib.
To be sure about the classpath, try putting them in JAVA_HOME/jre/lib/ext.
Java will see them.

Alberto.

 
 
 

org.gjt.mm.musql.Driver Error

Post by Alexander Emmanue » Wed, 16 Apr 2003 11:41:38


Hi again

I still have the problem when I try to run my servlet and connect to the
database. I don't know why?
Here is my code. I will be very gratefull if you look at it and tell me if
something is wrong. Otherwise can you tell any good web site with
information concerning a connection to mysql database using jdbc. Note that
I am using linux mandrake 9.0, tomcat 4.1.18, and mm.mysql-2.0.13. I am not
sure if i define well the url of my database? What exactly should I put
there?

Thank you in advance

Alex

import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Validate extends HttpServlet {

      public void doGet(HttpServletRequest req, HttpServletResponse res)
                            throws ServletException, IOException {
 res.setContentType("text/html");
 PrintWriter out = res.getWriter();

 out.println( "<html><title>Cannot Reload</title><body
bgcolor=#FFFFFF>\n" );
 out.println( "<h1>This page can not be reloaded\n" );
 out.println( "</h1></body></html>" );
 }

public void  doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
 res.setContentType("text/html");
 PrintWriter out = res.getWriter();

 //Get the user's account number and password
 String username = req.getParameter("USERNAME");
 String password = req.getParameter("PASSWORD");

 //Check the name and password for validity
 if (!allowUser(username, password)) {
  out.println("<HTML><HEAD>");
  out.println("<TITLE>Access Denied</TITLE>\n");
  out.println("<BR><BR><BODY BGCOLOR = \"#DFF1FF\">");
  out.println("<FONT FACE=Arial SIZE = 6 COLOR=Red><STRONG>\n");
  out.println("You entered an invalid login and password.<br>\n");
  out.println("Access has been denied.</STRONG></FONT></BODY>");
  out.println("<BR><BR><BR>\n<FONT SIZE = 6>");
  out.println("<A HREF = http://localhost:8080/servlets/validate.html>");
  out.println("Try again </A>\n<BR><BR>");
  out.println("<A HREF = http://localhost:8080/servlets/shop.html>");
  out.println("Go shopping </A>\n<BR><BR>");
  out.println("<A HREF = http://localhost:8080/servlets/insert.html>");
  out.println("Register </A>\n<BR><BR>");
  }
 else {
  out.println("<HTML><HEAD>");
  out.println("<TITLE>Thank you</TITLE>\n");
  out.println("<BODY BGCOLOR = \"#DFF1FF\">");
  out.println("<FONT SIZE = 3 COLOR = BLUE>");
  out.println("Permision has been granted </FONT>\n");
  out.println("<BR><BR><BR><FONT SIZE = 8 COLOR = BLUE>");
  out.println("Welcome back " + username );
  out.println(" ! <BR></FONT>\n");
  out.println("<BR><BR><BR>\n<FONT SIZE = 6>");
  out.println("<A HREF = http://localhost:8080/servlets/shop.html>");
  out.println("Go shopping</A></FONT>\n");
  }
 }

 protected boolean allowUser(String username, String password) {

 String login ;
 String pass ;

 try {
  Class.forName("org.gjt.mm.mysql.Driver");
  }
 catch (Exception E)  {
    System.err.println("Unable to load driver.");
    E.printStackTrace();
    }
 try {
  String url = "jdbc:mysql://localhost/project";

  Connection con = DriverManager.getConnection(url, "client", "alex");

  Statement stmt = con.createStatement();

  //Execute a select statement  to fetch login and password
  ResultSet rs = stmt.executeQuery("SELECT login, password FROM customers");

   while (rs.next()) {

   login = rs.getString(1);
   pass = rs.getString(2);

   if (username.equals( login ) ) {
   if (password.equals( pass ) ) { return true;}
   }
   }
    stmt.close();
    con.close();
   }
   catch (java.lang.Exception ex) {
    ex.printStackTrace();
   }
 return false;
 }

Quote:}

 
 
 

org.gjt.mm.musql.Driver Error

Post by jd.bonato » Sat, 19 Apr 2003 20:52:37


Examining your code, my remarks: 1) your doGet method makes no use of
the MySql driver, so the this error come from 2) your allowUser method
doesn't catch SQLException, maybe you should have more precise on the
error if it does.
For my personal install, I must tell which port to use to connect to
the Connector/J MySQL driver (port 3306) and everything works fine.
HTH
jd bonatout