================================================================================= Select * from studentinfo ================================================================================= import java.sql.*; class DbConnectivity{ public static void main(String args[]){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection( "jdbc:mysql://localhost:3306/student","root",""); //here student is database name, root is username and password Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from studentinfo"); while(rs.next()) System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)); con.close(); }catch(Exception e){ System.out.println(e);} } } ================================================================================= Select * from studentinfo where rollno='16EGJCS000'; ================================================================================= import java.sql.*; class DbConnectivityWhereCondition{ public static void main(String args[]){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection( "jdbc:mysql://localhost:3306/student","root",""); //here student is database name, root is username and password Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from studentinfo where rollno='16EGJCS000'"); while(rs.next()) System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)); con.close(); }catch(Exception e){ System.out.println(e);} } } ================================================================================= Create table StudentInfo SQL Command ================================================================================= CREATE TABLE `studentinfo` ( `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `studentname` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `college` varchar(100) NOT NULL, `rollno` varchar(100) NOT NULL, `password` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;