0

I have written down the code in Eclipse .. I even put connector jar file in project and set classpath too but it still throws RuntimeException.

package len;
import java.sql.*;

public class dbcon {

  public static void main(String[] args) {
    try{Class.forName("con.mysql.jdbc.Driver");
    Connection con= DriverManager.getConnection("jdbc:mysql://localhost//sample","root","");
    Statement s= con.createStatement();
    ResultSet rs=s.executeQuery("select * from user1 ");
    while(rs.next())
    {
        System.out.println(rs.getInt(1));
        System.out.println(rs.getString(2));
    }
    con.close();
    }
    catch(Exception e)
    {
        System.out.println(e);
    }
  }

}
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
Lenin Kumam
  • 11
  • 1
  • 3

1 Answers1

3

Use "com.mysql.jdbc.Driver"

Class.forName("com.mysql.jdbc.Driver");
Mustahsan
  • 3,852
  • 1
  • 18
  • 34