[Connector\J] NoClassDefFoundError

From: Grzegorz Wolny (frimanNOSPAM_at_gazeta.pl)
Date: 01/25/04

  • Next message: tommy: "Which database to choose"
    Date: Sun, 25 Jan 2004 14:57:38 +0100
    
    

    Hi!

    I know it has been asked here and in other groups before but none of the
    answers helped me.
    I'm trying to connect to MySQL using Connetor/J but when I test the
    driver I get the following error:
    "Exception in thread "main" java.lang.NoClassDefFoundError:
    com/stardeveloper/example/JdbcExample1"
    Here is my testing configuration:
    WinXP SP1, MySQL 4.0.17, j2sdk-1_4_1_02-windows-i586,
    mysql-connector-java-3.0.10-stable-bin.jar.

    The j2sdk is in C:\java\ the connector is in:
    C:\java\jre\lib\ext\mysql-connector-java-3.0.10-stable-bin.jar
    I don't know why the JRE is also in Program Files but i copied the
    connector also there:
    C:\Program
    Files\Java\j2re1.4.1_02\lib\ext\mysql-connector-java-3.0.10-stable-bin.jar
    My CLASSPATH is set as system variable:
    .;C:\java\jre\lib\ext\mysql-connector-java-3.0.10-stable-bin.jar

    I'm a newbie to java so I was trying to run a simple JDBC example from
    stardeveloper.com:

    package com.stardeveloper.example;

    import java.sql.*;

    public class JdbcExample1 {

       public static void main(String args[]) {
         Connection con = null;

         try {
           Class.forName("com.mysql.jdbc.Driver").newInstance();
           con = DriverManager.getConnection("jdbc:mysql:///db", "usr",
    "passwd");

           if(!con.isClosed())
             System.out.println("Successfully connected to MySQL server...");

         } catch(Exception e) {
           System.err.println("Exception: " + e.getMessage());
         } finally {
           try {
             if(con != null)
               con.close();
           } catch(SQLException e) {}
         }
       }
    }

    I ran it in many different ways, with and without the CLASSPATH, with
    the -cp (or -classpath), and I still got the same error. It compiles OK,
    when I run javac -verbose I get this output:

    C:\java\bin>javac -verbose JdbcExample1.java
    [parsing started JdbcExample1.java]
    [parsing completed 78ms]
    [loading C:\java\jre\lib\rt.jar(java/sql/Connection.class)]
    [loading C:\java\jre\lib\rt.jar(java/sql/DriverManager.class)]
    [loading C:\java\jre\lib\rt.jar(java/sql/SQLException.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/Object.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/String.class)]
    [checking com.stardeveloper.example.JdbcExample1]
    [loading C:\java\jre\lib\rt.jar(java/lang/Class.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/System.class)]
    [loading C:\java\jre\lib\rt.jar(java/io/PrintStream.class)]
    [loading C:\java\jre\lib\rt.jar(java/io/FilterOutputStream.class)]
    [loading C:\java\jre\lib\rt.jar(java/io/OutputStream.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/Exception.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/Throwable.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/Error.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/ClassNotFoundException.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/RuntimeException.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/InstantiationException.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/IllegalAccessException.class)]
    [loading C:\java\jre\lib\rt.jar(java/lang/StringBuffer.class)]
    [wrote JdbcExample1.class]
    [total 1750ms]

    I don't know what else could be the problem. Could somebody help me?

    G.W.


  • Next message: tommy: "Which database to choose"

    Relevant Pages

    • Re: Anyone use Devarts MyDirect.NET and/or dbForgeFusion for MySQL?
      ... So if you use a GPLed library in your app A, and you distribute A to your client, you can only do so if A meets the requirements of the GPL, as you distribute A and A uses a GPL-ed library. ... This means you either have to open source / GPL your own software OR pay a huge fee to MySql for every license you need. ... The Corelab connector isn't free, ...
      (microsoft.public.dotnet.framework.adonet)
    • Re: Anyone use Devarts MyDirect.NET and/or dbForgeFusion for MySQL?
      ... That's stupid as MySql should be interested in as much people connecting to their database. ... The Corelab connector isn't free, ... So unless you want to GPL your own work, ... Don't think lightly about the GPL license, it does force your own software to be GPL-ed as well if you distribute it, which means if you transfer it to another system you've to open up the sourcecode. ...
      (microsoft.public.dotnet.framework.adonet)
    • Re: mySQL and asp.net questions - PLEASE HELP
      ... mySQL, however, I have built an app that talked to mySQL and had web bits ... What type of connector to use to my database (i.e. ODBC or mySQL's ... Whether it is advised to bind you data to the web controls (e.g. ... I've read somewhere that binding asp controls to your mySQL ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Possible JDBC installation or usage problem in OS X
      ... connector-java-3.1.14-bin.jar" export CLASSPATH ... Servername.eg.net is the name of the server and 3306 is whatever port MySQL is configured for ... The next step is for you to write a 10-20 line Java program that simply attempts to open a connection and close it again. ...
      (comp.lang.java.databases)
    • Re: Anyone use Devarts MyDirect.NET and/or dbForgeFusion for MySQL?
      ... I installed the latest version of the MySQL Connector. ... lightly about the GPL license, it does force your own software to be ... We use it in our mysql driver/SQL engine in llblgen pro. ...
      (microsoft.public.dotnet.framework.adonet)