Steve Ruby wrote:
>
> Any one have any suggestions why I can't get the org.gjt.mm
> or twz1 jdbc drivers working. I'm not sure what I'm doing wrong
> I am considering java as a replacement for my C++/mysql apps
>
> The following excerpt from my doGet or service (I've used both)
> in a java servlet always results in ClassNotFoundException
>
> This will always trip a ClassNotFoundException
> but .getMessage() returns null I am getting basically
> the same result with the org.gjt.mm driver
>
> what am I doing wrong? Claspath has twz1.jdbc.mysql.jdbcMysqlDriver
> in it because i can put that in import and on
> javac -verbose it appears to load
>
> Thanks
> Steve
>
> try {
> //Load the driver
> Class.forName("twz1.jdbc.mysql.jdbcMysqlDriver");
>
> //Get a Connection to the database
> con = DriverManager.getConnection (url, "root","");
>
> //Create a Statement object
> stmt = con.createStatement();
Hi Steve
Do you have the JDBC driver (or its jar file) in your servlet CLASSPATH (not just your
system CLASSPATH)?
It is safer not just to use Class.forName(...) instead use:
Class.forName("twz1.jdbc.mysql.jdbcMysqlDriver").newInstance();
or:
DriverManager.registerDriver( new twz1.jdbc.mysql.jdbcMysqlDriver() );
This is because of a race condition that sometimes prevent the DriverManager to recognize
the driver.
BTW:
There is a java <-> mysql related mailinglist:
mailto:java@stripped
Tschau
Christian