How would i get the "Goal" value from my MySQL into a JLabel? Would i have to separate it into different functions?
Jlabel GOAL = new JLabel("");
try {
//connection to database
Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:8889/Daily", "student", "student");
Statement myStmt = myConn.createStatement();
ResultSet rs = myStmt.executeQuery("select Goal from User WHERE id=1");
GOAL.setText(rs.getString("Goal"));
}
catch (Exception e) {
e.printStackTrace();
}
GOAL.setForeground(Color.LIGHT_GREEN);
GOAL.setBounds(23, 90, 61, 45);
contentPane.add(GOAL);
`