3 messages in com.mysql.lists.javaRe: Getting started with mm.mysql 2.0.2
FromSent OnAttachments
Cary Collett06 Sep 2000 11:41 
Mark Matthews06 Sep 2000 11:51 
Cary Collett06 Sep 2000 12:38 
Subject:Re: Getting started with mm.mysql 2.0.2
From:Mark Matthews (mmat@thematthews.org)
Date:09/06/2000 11:51:36 AM
List:com.mysql.lists.java

You can drop the .jar file in the jre/lib/ext directory inside your JDK. It will then automatically be added to an internal classpath that the VM always sees.

-Mark

Cary Collett wrote:

No change. I didn't think it would make a difference since it seems to be crapping out at 'Class.forName("org.gjt.mm.mysql.Driver").newInstance();' not where it tries to make the connection.

Near as I can tell it simply doesn't see the jar file, no matter where I put it. I've tried the cwd too.

Cary

Thus spake Jason Webber (web@mminternet.com):

try changing DriverManager.getConnection("jdbc:z1MySQL://localhost/sffh?user=blah&password=blahblah"); to DriverManager.getConnection("jdbc:mysql://localhost/sffh?user=blah&password=blahblah");

Cary Collett wrote:

Hello all,

I'm fairly new to java so bear with what is probably a very simple problem/question.

I am trying to run an app which does a simple connect and select using mysql 3.23.23, Sun JDK 1.2.2 and mm.mysql-2.0.2 on a Red Hat Linux 6.2 box.

It compiles with no errors, but then complains that it can't find the class:

Unable to load driver. java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:201) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:295) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:282) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:311) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) at QuerySFFH.main(QuerySFFH.java:14) SQLException: No suitable driver SQLState: 08001 VendorError: 0

If I set the CLASSPATH to /usr/local/jdk1.2.2/jre/lib (where the mm.mysql jar file is) I get this:

Exception in thread "main" java.lang.NoClassDefFoundError: QuerySFFH

QuerySFFH.java and .class both exists and there is a 'public class QuerySFFH' declaration.

Here is the code itself:

import java.sql.*;

public class QuerySFFH { public static void main(String[] Args) { Connection conn = null; Statement stmt = null; ResultSet rs = null;

try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (Exception e) { System.err.println("Unable to load driver."); e.printStackTrace(); }

try { conn =
DriverManager.getConnection("jdbc:z1MySQL://localhost/sffh?user=blah&password=blahblah");

stmt = conn.createStatement();

rs = stmt.executeQuery("SELECT title from Books WHERE bookid < 10");

while (rs.next()) { System.out.println(rs.getString(1)); }

// Clean up after ourselves rs.close(); stmt.close(); conn.close();

} catch (SQLException E) { System.out.println("SQLException: " + E.getMessage()); System.out.println("SQLState: " + E.getSQLState()); System.out.println("VendorError: " + E.getErrorCode()); }

} }

So, what the heck am I doing wrong?

Thanks! Cary

-- Cary Collett ca@ratatosk.org http://ratatosk.org/~cary

"To me boxing is like ballet, except that there's no music, no choreography, and the dancers hit eachother." -- Jack Handy

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java@lists.mysql.com instead.

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java@lists.mysql.com instead.