Facebook
From Fardin, 9 Months ago, written in Java.
Embed
Download Paste or View Raw
Hits: 379
  1. package labpractice;
  2.  
  3. public class MysqlCon {
  4.     public static void main(String[] args) {
  5.         try{
  6.             Class.forName("com.mysql.jdbc.Driver");
  7.             Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/ict","root","root");
  8.             Statement stmt=con.createStatement();
  9.             ResultSet rs=stmt.executeQuery("select * from emp");
  10.             while(rs.next())
  11.                 System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
  12.             con.close();
  13.         }catch(Exception e){System.out.println(e);}
  14.     }
  15. }
  16.