I am trying to populate options for a combo box named cmb_course, the options will be pulled from my database in microsoft access, my problem is on the line below
cmb_course.addItem(rs.getString("courseName"));
cmb_course
gets highlighted in red with the error
"cannot find symbol symbol: variable cmb_course location: class student"
my main file is the studentForm.java
the file where the combo box named cmb_course
has been created is studentJframe.java
and finally I created another class which is the student.java
where I am trying to build the function.
I have researched about using a getter and setter for this but I am fairly new to jframe and cannot fully grasp the concept that much because this was not yet explained to us by the professor yet it was given as part of our project
I hope someone can elaborate on this matter.
public class student {
final String K_LIB = "jdbc:ucanaccess://";
final String K_DB_LOC = "C://";
final String K_DB_NAME = "students.accdb";
String configuration = K_LIB + K_DB_LOC + K_DB_NAME;
public void fillComboBox(){
try{
Connection conn = DriverManager.getConnection(configuration);
Statement s = conn.createStatement();
ResultSet rs=s.executeQuery("Select courseName from course");
while(rs.next()){
cmb_course.addItem(rs.getString("courseName"));
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
}