Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package prac5;
- import java.sql.*;
- /**
- *
- * @author Kanu
- */
- public class Prac5 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws Exception{
- int count =0;
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
- Statement st = con.createStatement();
- ResultSet rs = st.executeQuery("SELECT * FROM student");
- ResultSetMetaData rsmd = rs.getMetaData();
- while (rs.next()){
- count = rs.getInt(1);
- }
- System.out.println("Number of row:"+count);
- System.out.println("columns: "+rsmd.getColumnCount());
- System.out.println("Column Types: "+rsmd.getColumnTypeName(1)+" , "+rsmd.getColumnTypeName(2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement