tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Flaumenhaft <shari...@pacbell.net>
Subject Re: MySQL question - No suitable driver
Date Tue, 27 Feb 2001 23:58:11 GMT

Connie,

Your problem is most likely *not* that it can't find the classes, but that
it hasn't associated the URL with the appropriate class.

Try adding the following call anytime before you get the connection:

    Class.forName ("org.gjt.mm.mysql.Driver");

This tells the VM to actually load the class, at which point the classloader
calls static initializers on that class. Static inits for a JDBC driver
register it with the DriverManager, effectively saying "anytime anyone asks
for anything jdbc:mysql:..., use me." Until the class has been statically
initialized (that is, loaded explicitly), you can't use getConnection ().

Hope that helps.

Regards,
Ben Flaumenhaft
Principal, Sidelight Consulting
http://www.sidelight.com

----- Original Message -----
From: "Wong, Connie" <connie.wong@lmco.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Tuesday, February 27, 2001 11:56 AM
Subject: MySQL question - No suitable driver


> Hi,
>
> I try to connect a servlet talk to the MySQL database.
>      I set:
>
>      drivername = "org.gjt.mm.mysql.Driver" and
>                  url = "jdbc:mysql:tbl_data"
>
> I downloaded MyODBC and fill in the ODBC setup and add the
> "mm_mysql-2_0_2-bin.jar" in the classpath.
>
> When I run my servlet on the browser, it display the following Exception:
>
>
> java.sql.SQLException: No suitable driver at
> java.sql.DriverManager.getConnection(DriverManager.java:537) at
> java.sql.DriverManager.getConnection(DriverManager.java:146) at
> Benchmark_sql.query(Benchmark_sql.java:94) at
> Benchmark_sql.doGet(Benchmark_sql.java:47) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:597)
> at
> org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java:160) at
>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
> ) at java.lang.Thread.run(Thread.java:484) n
>
>
> Can someon tell me what else I do miss?
> Thanks,
> Connie
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
>


Mime
View raw message