Advertisement
Guest User

Untitled

a guest
Feb 4th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package prac5;
  7.  
  8. import java.sql.*;
  9. /**
  10. *
  11. * @author Kanu
  12. */
  13. public class Prac5 {
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) throws Exception{
  19. int count =0;
  20. Class.forName("com.mysql.jdbc.Driver");
  21.  
  22. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
  23. Statement st = con.createStatement();
  24. ResultSet rs = st.executeQuery("SELECT * FROM student");
  25. ResultSetMetaData rsmd = rs.getMetaData();
  26.  
  27. while (rs.next()){
  28. count = rs.getInt(1);
  29. }
  30. System.out.println("Number of row:"+count);
  31. System.out.println("columns: "+rsmd.getColumnCount());
  32. System.out.println("Column Types: "+rsmd.getColumnTypeName(1)+" , "+rsmd.getColumnTypeName(2));
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement