JDBC + Mandrake Linux + Mysql + netbeans

I'm trying to conecto to a mysql server using the following code of netbeans. It compiles, but I got a java.lang.NoClassDefFoundError on execution time.

Does anyone have any clue of how to solve it?

(I got the netbeans+sdk package, is it complete? Maybe the jdbc class is missing? Where can I get it?)

Thanks!

import java.sql.*;

public class Connect

{

public static void main (String[] args)

{

Connection conn = null;

try

{

String userName = "root";

String password = "kron9013";

String url = "jdbc:mysql://192.168.0.109/Solbet";

Class.forName ("com.mysql.jdbc.Driver").newInstance ();

conn = DriverManager.getConnection (url, userName, password);

System.out.println ("Database connection established");

}

catch (Exception e)

{

System.out.println (e.toString());

System.err.println ("Cannot connect to database server");

}

finally

{

if (conn != null)

{

try

{

conn.close ();

System.out.println ("Database connection terminated");

}

catch (Exception e) { /* ignore close errors */ }

}

}

}

}

Exception in thread "main" java.lang.NoClassDefFoundError: mysql/Connect (wrong name: Connect)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:537)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)

at java.net.URLClassLoader.access$100(URLClassLoader.java:55)

at java.net.URLClassLoader$1.run(URLClassLoader.java:194)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:187)

at java.lang.ClassLoader.loadClass(ClassLoader.java:289)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)

at java.lang.ClassLoader.loadClass(ClassLoader.java:235)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)



[2159 byte] By [robertoneto123] at [2007-9-30 2:54:12]
# 1
You can get the MySQL JDBC drivers from here: http://www.mysql.com/products/connector-j/index.htmlThen you just need to put them in your classpath and everything should work.
kobaia27 at 2007-6-29 10:51:21 > top of Java-index,Administration Tools,Sun Connection...
# 2
On this line:Class.forName ("com.mysql.jdbc.Driver").newInstance (); I'm 99.99% sure you can drop the newInstance() part. However, I'm not certain if that's why it's failing.
inco5 at 2007-6-29 10:51:21 > top of Java-index,Administration Tools,Sun Connection...