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(); } } }