import java.sql.*; import javax.swing.*; public class appl_02 { public static void main(String[] args) throws Exception { String url = "jdbc:mysql://aragorn.elo.utfsm.cl/arg_musiteca"; String login = "antares"; String pass = ""; Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url,login,pass); if (conn != null) { Statement stmt = conn.createStatement(); String sql = "select NOMBRE from DISCOS"; ResultSet rs = stmt.executeQuery(sql); System.out.println("Discos"); System.out.println("------"); while (rs.next()) { String r = rs.getString("NOMBRE"); System.out.println(r); } sql = "select NOMBRE from INTERPRETES"; rs = stmt.executeQuery(sql); System.out.println(" "); System.out.println("INTERPRETES"); System.out.println("-----------"); while (rs.next()) { String r = rs.getString("NOMBRE"); System.out.println(r); } conn.close(); } } catch(SQLException ex) { System.out.println(ex); } catch(ClassNotFoundException ex) { System.out.println(ex); } } }