JSP file
......................................…
Code:
//reading params from the form
String name = request.getParameter("name");
String year_prime = request.getParameter("year");
int year = Integer.parseInt(year_prime);
//inserting the params into table Students
StudentsManager.getInstance().
fillStudents(name, year);
// here I have the "fillStudents underlined"
......................................…
_____________________________________
Java file
________
Code:
public class StudentsManager {
private static StudentsManager instance;
private StudentsManager(){
}
public static StudentsManager getInstance(){
if (instance == null){
instance = new StudentsManager();
}
return instance;
}
public static void fillStudents(String name, int year){
Connection con = ConnectionsManager.getInstance()
.getConnection();
Statement stmt = ConnectionsManager.getInstance()
.getStatement(con);
try {
stmt.executeUpdate("insert into students(name,year) values('"+name+"', year)");
} catch (SQLException e) {
e.printStackTrace();
}
}
......................................…
The error says:
- The method fillStudents(String, int) is undefined the type StudentsManager.
The warning says:
- The static method fillStudents(String, int) from the type StudentsManager should be accessed in a static way.