What exactly am I doing wrong?
I'm trying to retrieve data from a database written in MySQL, however there seems to be a problem with my code. I'm completely new to SQL and JDBC, so it's probably quite a stupid mistake. Can anyone please point me in the right direction?
Code:
try {
Class.forName(driver);
con = DriverManager.getConnection(url, userName, password);
try {
Statement st = con.createStatement();
ResultSet executeQuery = st.executeQuery(queryCode);
System.out.println(executeQuery.getString(1));
} catch (Exception e) {
System.out.println("Code not executed");
}
} catch (Exception e) {
System.out.println("Not connected");
}