I have this program:
class DataRetrieve {
DataRetrieve() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/phonebook", "root", "1234");
Statement st = con.createStatement();
st.executeQuery("select * from contacts");
}
catch(Exception e) {
e.printStackTrace();
}
}
}
public class MainProgram {
public static void main(String[] args) {
DataRetrieve dr = new DataRetrieve();
//here i want to print that table rows into Console using this
System.out.println(); // How do you print here that table rows?
}
}
Can anyone explain how to print this database information in System.out.println
?