Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006

    Unanswered: connect to database in mysql using jdbc

    I am currently working under fedora core 4. I have created a database called root in mysql. I was trying to connect to database using jdbc but i get so many errors. I have checked de classpath and it is perfect. the source code is as follows

    String driver = "com.mysql.jdbc.Driver";

    System.out.println( "=> loading driver:" );
    Class.forName( driver );
    System.out.println( "OK" );

    /* Test the connection */

    String url = "jdbc:mysql://root.localhost/root";

    System.out.println( "=> connecting:" );
    DriverManager.getConnection( url, "root", "password" );
    System.out.println( "OK" );
    catch( Exception x ) {

    the errors i get are

    Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class : com.mysql.jdbc.NonRegisteringDriver
    at java.lang.VMClassLoader.transformException( ng.Class, java.lang.Thro wable) (/usr/lib/
    at java.lang.VMClassLoader.resolveClass(java.lang.Cla ss) (/usr/lib/ 6.0.0)
    at java.lang.Class.initializeClass() (/usr/lib/
    at java.lang.Class.initializeClass() (/usr/lib/
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/
    at java.lang.Class.forName(java.lang.String) (/usr/lib/
    at TestMysql.main(java.lang.String[]) (Unknown Source)
    at (/usr/lib/
    at (/usr/lib/
    Caused by: java.lang.ClassNotFoundException: org.aspectj.runtime.reflect.Factory not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./,file:/usr/ local/packages/mysql-connector-java.jar,file:./], parent=gnu.gcj.runtime.Extensi onClassLoader{urls=[], parent=null}}
    at ) (/usr/lib/ 0.0)
    at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgc
    at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/ 0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/

    please help me

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    may be better to ask this in the Java thread.....
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jul 2004
    What version of JDK you are running

  4. #4
    Join Date
    Jan 2006
    try to look in your library path.. mysql***.jar must be in your path

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts