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