Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: ClassNotFoundException ???

  1. #1
    Member wolfgar's Avatar
    Join Date
    Oct 2009
    Location
    the middle of the woods
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default ClassNotFoundException ???

    completely new to this part, and took the code with only slight changed from a book so ..

    heres what i have
    	private static Connection getConection(){
    		Connection conect = null;
    		try {
    			Class.forName("com.mysql.jdbc.Driver");
    			String url = "jdbc:mysql://localhost/players";
    			String user = "root";
    			String pw = "********";
    			conect = DriverManager.getConnection(url, user, pw);
    		}catch(ClassNotFoundException e){
    			System.out.println("Class not Found: " + e.getMessage());
    			System.exit(0);
    		}catch(SQLException e){
    			System.out.println("SQL Error: " + e.getMessage());
    			System.exit(0);
    		}
    		return conect;
    	}

    and i get "Class not Found: com.mysql.jdbc.Driver" when i run it . why doesn't it work ?

    notes:
    i just installed the mysql java connection
    and installed some kind of java database that i though i needed XP

    [ >.< it was an eclipse problem XP , i didnt load the jar file to there thinking it wold just recognize it *fails* ]
    Last edited by wolfgar; November 28th, 2009 at 03:38 PM.
    Programming: the art that fights back


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: ClassNotFoundException ???

    You need the MySQL connector jar file on your classpath.

    // Json

  3. #3
    Member wolfgar's Avatar
    Join Date
    Oct 2009
    Location
    the middle of the woods
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: ClassNotFoundException ???

    i had just put that in b4 i started coding that

    but encase i did it wrong heres a pic of where i put it and the value of the Classpath var

    it still doesnt work even though i have that
    Attached Images Attached Images
    Last edited by wolfgar; November 21st, 2009 at 05:19 PM.
    Programming: the art that fights back

Similar Threads

  1. ClassNotFoundException (bit weird)
    By chronoz13 in forum Exceptions
    Replies: 1
    Last Post: April 26th, 2011, 02:15 AM
  2. [SOLVED] ClassNotFoundException - Please Help
    By igniteflow in forum Exceptions
    Replies: 11
    Last Post: October 3rd, 2010, 10:50 PM