Guest User

Untitled

a guest
Apr 5th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. //initialize the connection
  2. try{
  3. Connection conn1=DriverManager.getConnection("jdbc:mysql://localhost/test","root","****");
  4. String query1= "SELECT * FROM student_table";
  5. Statement stmt1= conn1.createStatement();
  6. ResultSet res1=stmt1.executeQuery(query1);
  7.  
  8.  
  9. // Print the result
  10. System.out.println("id tt "+"namett "+"classttt "+"agen");
  11.  
  12. while(res1.next()){
  13. System.out.println(res1.getString("id")+"tt "
  14. +res1.getString("name")+"tt "
  15. +res1.getString("class")+"tt "
  16. +res1.getString("age"));
  17. }
  18. }catch(Exception e){
  19. System.err.println(e);
  20. }
  21. }
Add Comment
Please, Sign In to add comment