"NoClassDefFoundError" problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: "NoClassDefFoundError" problem

  1. #1
    Join Date
    Oct 2002
    Posts
    1

    "NoClassDefFoundError" problem

    I have downloaded a sample program from wrox Inc. but when I run it under JBuilder6, it prompt the problem. It'll be very appreciated if anyone can tell me how to make it run correctly?
    import java.sql.*;

    public class EssentialJDBC
    {
    public static void main (String[] args)
    {
    EssentialJDBC SQLExample = new EssentialJDBC();
    SQLExample.getResults();
    }

    EssentialJDBC()
    {
    try
    {
    Class.forName("jdbc.com.mysql.jdbc.Driver");
    con = DriverManager.getConnection("jdbc:mysql://localhost/dc");
    stmt = con.createStatement();
    }
    catch (ClassNotFoundException e)
    {
    System.out.println("Couldn't load database driver: " + e.getMessage());
    }
    catch (SQLException e)
    {
    System.out.println("SQLException caught: " + e.getMessage());
    }

    }// end constructor


    public void getResults(){
    try{
    rs = stmt.executeQuery(strSQL);
    int row=0;

    while(rs.next())
    System.out.println("Row"+(++row)+")"+
    rs.getString("title")+" "+
    rs.getString("creator"));

    rs.close();
    }
    catch(SQLException sqle)
    {
    System.err.println("\nSQLException-------------------------\n");
    System.out.println("SQLState: " + sqle.getSQLState());
    System.out.println("Message :" + sqle.getMessage());
    }
    }//end getResults

    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String strSQL = "SELECT title,creator from dc";
    }//end EssentailJDBC

  2. #2
    Join Date
    Aug 2002
    Posts
    94
    Hi,
    I think that the problem is in this line

    DriverManager.getConnection("jdbc:mysql://localhost/dc");

    there is no port number given and also no username and password for this application to initiate connection with database.

    Have you configured the JDBC driver on your machine and added it to your classpath?

    bye

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center