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 2 of 2

Thread: ClassNotFoundException Mysql

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ClassNotFoundException Mysql

    following is my java code. m new to java and trying to connect with mysql. i have added mysql-connector.jar in jre/lib/ext and jre/lib
    but still m getting this exception. i m using textpad and running mysql in xampp server. what wrong m doing as m getting the exception every time i try to run. please help


     
    import java.sql.*;
     
    class MysqlCon{
    public static void main(String args[]){
    try{
    Class.forName("com.mysql.jdbc.Driver");
     
    //Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
    Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test","root","root");
    //here test is the database name, root is the username and root is the password
    Statement stmt=con.createStatement();
     
    ResultSet rs=stmt.executeQuery("select * from person");
     
    while(rs.next())
    System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));
     
    con.close();
     
    }catch(Exception e){
     
    	//System.out.println(e);
    	e.printStackTrace();
     
     
    }
     
    }
    }
    Attached Images Attached Images


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,152
    Thanks
    49
    Thanked 2,158 Times in 2,131 Posts

    Default Re: ClassNotFoundException Mysql

    Have you tried putting the jar file in the -cp option on the commandline?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Getting ClassNotFoundException error.
    By kunalgaurav18 in forum JDBC & Databases
    Replies: 1
    Last Post: January 2nd, 2013, 07:46 AM
  2. glassfish ClassNotFoundException java.lang.ClassNotFoundException: ...
    By enginco in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: June 18th, 2012, 12:18 PM
  3. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    By i4ba1 in forum JDBC & Databases
    Replies: 2
    Last Post: August 23rd, 2011, 12:41 PM
  4. [SOLVED] ClassNotFoundException - Please Help
    By igniteflow in forum Exceptions
    Replies: 11
    Last Post: October 3rd, 2010, 10:50 PM
  5. ClassNotFoundException ???
    By wolfgar in forum JDBC & Databases
    Replies: 2
    Last Post: November 20th, 2009, 12:35 PM

Tags for this Thread