Guest User

Untitled

a guest
Sep 21st, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import java.io.*;
  2. import java.sql.*;
  3. class Enroll
  4. {
  5. public static void main(String args[])throws Exception
  6. {
  7. Class.forName("com.mysql.jdbc.Driver");
  8. Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/ted","root","12345");
  9. Statement st=cn.createStatement();
  10. String sub="Phy";
  11. ResultSet rs=st.executeQuery("select * from Student where branch=Phy");
  12. System.out.println("Roll No. /t Name /t Branch");
  13. while(rs.next())
  14. System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3));
  15. }
  16. }
Add Comment
Please, Sign In to add comment