Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.sql.*;
- class Enroll
- {
- public static void main(String args[])throws Exception
- {
- Class.forName("com.mysql.jdbc.Driver");
- Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/ted","root","12345");
- Statement st=cn.createStatement();
- String sub="Phy";
- ResultSet rs=st.executeQuery("select * from Student where branch=Phy");
- System.out.println("Roll No. /t Name /t Branch");
- while(rs.next())
- System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3));
- }
- }
Add Comment
Please, Sign In to add comment