import java.sql.*; final class SQL { final static String user = "root"; final static String password = "root"; final static String db = "database"; final static String jdbc = "jdbc:mysql://localhost:3306/"+db+"?user="+user+"&password="+password; public static void main ( String[] args ) throws Exception { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection(jdbc); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from employee"); while (rs.next()) System.out.println(rs.getString("fname")+" "+rs.getString("lname")); rs.close(); stmt.close(); con.close(); } }