Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie help with mysql and java

1 view
Skip to first unread message

don

unread,
Aug 22, 2003, 9:49:03 PM8/22/03
to
I am new to java and have a problem with java finding the mysql driver.
i am encluding the errors and java code. I can't find anything wrong, so i
figure it might be a config file entry.

Thanks in advance for any help.
don

java Exec
Executing:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at Exec.main(djtest2.java:15)

import java.sql.*;
class Exec {
public static void main(String args[]) {
String sql = "";

for(int i=0; i<args.length; i++) {
sql = sql + args[i];
if( i < args.length - 1 ) {
sql = sql + " ";
}
}
System.out.println("Executing: " + sql);
try {
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://localhost/mp3";
Connection con = DriverManager.getConnection(url, "dj", "mystic");
Statement s = con.createStatement();


the driver is located at
/usr/lib/java/sql/com/jdbc/driver.class

J

unread,
Aug 22, 2003, 10:24:13 PM8/22/03
to
On Fri, 22 Aug 2003 21:49:03 -0400, don wrote
(in message <pan.2003.08.23...@comcast.net>):

execute the class like this

java -classpath /usr/lib/java/sql/com/jdbc/mysql.jar Exec

mysql.jar should be the jar file that the mysql driver is in. or if there is
no jar just class files, then execute like this

java -classpath /usr/lib/java/sql/com/jdbc/ Exec

That should do it.

J

Dave Miller

unread,
Aug 23, 2003, 11:32:08 AM8/23/03
to
In article <0001HW.BB6C488D005562EFF0284600@news-
server.tampabay.rr.com>, webs...@fluidic.com says...
As an alternative to the classpath option shown above, you can also put
a copy of the jar into the /lib/ext directory of your JRE

don

unread,
Aug 23, 2003, 12:01:01 PM8/23/03
to

Thnaks for the input, now the error has changed, when i run Exec
with -classpath as shown above i get this error

ava -classpath /usr/lib/java/sql/com/jdbc/ Exec
Exception in thread "main" java.lang.NoClassDefFoundError: Exec


any thoughts?
I thank you so vewry much for your help
don

Georg Stahl

unread,
Aug 23, 2003, 12:47:54 PM8/23/03
to
don wrote:

> Thnaks for the input, now the error has changed, when i run Exec
> with -classpath as shown above i get this error
>
> ava -classpath /usr/lib/java/sql/com/jdbc/ Exec
> Exception in thread "main" java.lang.NoClassDefFoundError: Exec
>
>
> any thoughts?
> I thank you so vewry much for your help

nowr Exec is outside the Classpath. Add the active directory to the
classpath. Try: java -cp .:/usr/lib/java/sql/com/jdbc/ Exec

Georg


0 new messages