public class Portdetails { public static void main(String[] args) { try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); try ( Connection cn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/airportinfo","root","")) { Statement smt=(Statement) cn.createStatement(); //query to display all records from table employee String q="SELECT * FROM airportinfo"; //to execute query ResultSet rs=smt.executeQuery(q); //to print the resultset on console if(rs.next()){ do{ System.out.println(rs.getString(1)+"--"+rs.getString(2)+"--"+rs.getString(3)+"--"+rs.getString(4)); }while(rs.next()); } else{ System.out.println("Record Not Found..."); } } } catch(Exception e) { System.out.println(e); } } }
System.out.println
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)