You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Angela Stempfel <hi...@gmx.ch> on 2001/05/05 14:35:33 UTC

Tomcat-MySQL connection problem

Hi all,

The past hours I tried to set up Tomcat on my local Win2000 box. I've
installed the lastest MySQL package and also the latest Tomcat version I
got.

After I've read the manual of the JDBC Driver I was able to set it up
that I can connect to MySQL with my short Java Class I wrote. This class
simply creates some tables in MySQL, so far so good.
Afterwards I tried to use exactly the same way of connecting to MySQL in
my JSP Files, again using Java to connect to MySQL. But it doesn't
matter how I try to do it, I always get the
"javax.servlet.ServletException: No suitable driver..." Exception.

I connect like this:

   try
        {
        Class.forName("org.gjt.mm.mysql.Driver").newInstance();
        }

        catch(Exception e)
        {
            System.err.println("Unable to load driver.");
            e.printStackTrace();
        }

        con =
DriverManager.getConnection("jdbc:mysql://localhost/horse");

As I said this *works* if I do that with a simple Java test-Class, but
not after I try to do it in Tomcat. Classpath should be correct, at
least I double checked it about 100 times. The Java files I use are in a
package, could that be a problem? The test files are not in the package
(to be honest, I don't really understand this package stuff :-)

I've also tried to add the port (3306 which seems to be default port in
MySQL) after localhost but this doesn't help. Is there a way to check if
the port is really used in Windows?

I'm really running out of ideas now, I checked all the information I
found, checked the web on other mailinglists (google rulez) and every
thing I tried did not help so far. So any suggestions are very welcome
:-)

thanks in advance

Angela


Solved! (Was Re: Tomcat-MySQL connection problem)

Posted by Angela Stempfel <hi...@gmx.ch>.
Hi Wolle, hi Brahmanand,

Thanks a lot for your tips, it works now. My weekend is saved :-))

I think it did not work the first time because I used the src package instead of
the binary.

have a nice weekend

cu

Angela




Log tracking program

Posted by Brandon Cruz <bc...@norvax.com>.
Does anyone know of a program (hopefully free) that can track and parse the
log files of a tomcat-apache configuration.  We are looking for basic stats,
such as total hits, unique page views, specific file views (images, pages,
etc.)  Any help or tips to get me looking in the right direction would be
greatly appreciated.

Thanks!

Brandon Cruz


Re: Tomcat-MySQL connection problem

Posted by Wolle <wo...@dorf.RWTH-Aachen.DE>.
Hei,
if this doesn't work.
Put the .jar file in your TOMCAT/webapps/YOUR_APPL/WEB-INF/lib.
When you put your .jar file in here, it's only accessible for this
WEB-Application.
When you put it in TOMCAT/lib it's accessible to all your Servlets/JSP.
You could also put it into your JDK/jre/lib/ext directory, so it's available
to all your Java Applicaitons.
I have read something about putting the .jar file in /JDK.... could cause
some errors.

Greetings,
Michael

Brahmanand Gannur wrote:

> put the  mysql driver( .jar )  into the lib directory of the TOMCAT and
> restart the tomcat
> hope this helps
>
> -----Original Message-----
> From: Angela Stempfel [mailto:hippie@gmx.ch]
> Sent: Saturday, May 05, 2001 6:06 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Tomcat-MySQL connection problem
>
> Hi all,
>
> The past hours I tried to set up Tomcat on my local Win2000 box. I've
> installed the lastest MySQL package and also the latest Tomcat version I
> got.
>
> After I've read the manual of the JDBC Driver I was able to set it up
> that I can connect to MySQL with my short Java Class I wrote. This class
> simply creates some tables in MySQL, so far so good.
> Afterwards I tried to use exactly the same way of connecting to MySQL in
> my JSP Files, again using Java to connect to MySQL. But it doesn't
> matter how I try to do it, I always get the
> "javax.servlet.ServletException: No suitable driver..." Exception.
>
> I connect like this:
>
>    try
>         {
>         Class.forName("org.gjt.mm.mysql.Driver").newInstance();
>         }
>
>         catch(Exception e)
>         {
>             System.err.println("Unable to load driver.");
>             e.printStackTrace();
>         }
>
>         con =
> DriverManager.getConnection("jdbc:mysql://localhost/horse");
>
> As I said this *works* if I do that with a simple Java test-Class, but
> not after I try to do it in Tomcat. Classpath should be correct, at
> least I double checked it about 100 times. The Java files I use are in a
> package, could that be a problem? The test files are not in the package
> (to be honest, I don't really understand this package stuff :-)
>
> I've also tried to add the port (3306 which seems to be default port in
> MySQL) after localhost but this doesn't help. Is there a way to check if
> the port is really used in Windows?
>
> I'm really running out of ideas now, I checked all the information I
> found, checked the web on other mailinglists (google rulez) and every
> thing I tried did not help so far. So any suggestions are very welcome
> :-)
>
> thanks in advance
>
> Angela


Re: Tomcat-MySQL connection problem

Posted by Wolle <wo...@dorf.RWTH-Aachen.DE>.
How do you create an Instance of this driver ?
Do you use the static call class.forName(driver) ?
Try the extend it with class.ForName(driver).newInstance(),
this must be done on some VM .

Greetings,
Michael

Wolle wrote:

> Hello,
> try the mm.mysql-2.0.4-bin.jar file, not the source file.
>
> Greetings,
> Michael
>
> Angela Stempfel wrote:
>
> > Brahmanand Gannur wrote:
> >
> > > put the  mysql driver( .jar )  into the lib directory of the TOMCAT and
> > > restart the tomcat
> > > hope this helps
> >
> > I now copied the mm.mysql-2.0.4-src.jar to the lib directory of TOMCAT and
> > restarted it. However, it did not help as well. Is there any way to debugg
> > the problem to get more information where exactly it fails?
> >
> > thanks
> >
> > Angela


Re: Tomcat-MySQL connection problem

Posted by Wolle <wo...@dorf.RWTH-Aachen.DE>.
Hello,
try the mm.mysql-2.0.4-bin.jar file, not the source file.

Greetings,
Michael

Angela Stempfel wrote:

> Brahmanand Gannur wrote:
>
> > put the  mysql driver( .jar )  into the lib directory of the TOMCAT and
> > restart the tomcat
> > hope this helps
>
> I now copied the mm.mysql-2.0.4-src.jar to the lib directory of TOMCAT and
> restarted it. However, it did not help as well. Is there any way to debugg
> the problem to get more information where exactly it fails?
>
> thanks
>
> Angela





Re: Tomcat-MySQL connection problem

Posted by Angela Stempfel <hi...@gmx.ch>.
Brahmanand Gannur wrote:

> put the  mysql driver( .jar )  into the lib directory of the TOMCAT and
> restart the tomcat
> hope this helps

I now copied the mm.mysql-2.0.4-src.jar to the lib directory of TOMCAT and
restarted it. However, it did not help as well. Is there any way to debugg
the problem to get more information where exactly it fails?

thanks

Angela


RE: Tomcat-MySQL connection problem

Posted by Brahmanand Gannur <br...@futureach.com>.
put the  mysql driver( .jar )  into the lib directory of the TOMCAT and
restart the tomcat
hope this helps

-----Original Message-----
From: Angela Stempfel [mailto:hippie@gmx.ch]
Sent: Saturday, May 05, 2001 6:06 PM
To: tomcat-user@jakarta.apache.org
Subject: Tomcat-MySQL connection problem


Hi all,

The past hours I tried to set up Tomcat on my local Win2000 box. I've
installed the lastest MySQL package and also the latest Tomcat version I
got.

After I've read the manual of the JDBC Driver I was able to set it up
that I can connect to MySQL with my short Java Class I wrote. This class
simply creates some tables in MySQL, so far so good.
Afterwards I tried to use exactly the same way of connecting to MySQL in
my JSP Files, again using Java to connect to MySQL. But it doesn't
matter how I try to do it, I always get the
"javax.servlet.ServletException: No suitable driver..." Exception.

I connect like this:

   try
        {
        Class.forName("org.gjt.mm.mysql.Driver").newInstance();
        }

        catch(Exception e)
        {
            System.err.println("Unable to load driver.");
            e.printStackTrace();
        }

        con =
DriverManager.getConnection("jdbc:mysql://localhost/horse");

As I said this *works* if I do that with a simple Java test-Class, but
not after I try to do it in Tomcat. Classpath should be correct, at
least I double checked it about 100 times. The Java files I use are in a
package, could that be a problem? The test files are not in the package
(to be honest, I don't really understand this package stuff :-)

I've also tried to add the port (3306 which seems to be default port in
MySQL) after localhost but this doesn't help. Is there a way to check if
the port is really used in Windows?

I'm really running out of ideas now, I checked all the information I
found, checked the web on other mailinglists (google rulez) and every
thing I tried did not help so far. So any suggestions are very welcome
:-)

thanks in advance

Angela