I know that setString permits to insert a value in specified position, now I want get checkbox values from the jsp page in order to pass it to the database.
I defined the variable of checkbox as a String array since it may handle one or more values.
This is how I defined it the variable in the class:
public String[] rep;
This is how my servlet shall retrieve this parameter in the doPost method:
String[] rep = request.getParameterValues("rep");
and this is a line from my DAO class from the preparedStatement query:
st.setString(3, exam.rep);
but that is shown this error: The method setString(int, String) in the type PreparedStatement is not applicable for the arguments (int, String[])
the whole query
public static void add(Exam exam) throws ClassNotFoundException, SQLException {
Connection cnx;
cnx = Connect.getConnection();
String req = "insert into examen values (?,?,?)";
PreparedStatement st = cnx.prepareStatement(req);
st.setString(1, exam.titre);
st.setString(2, exam.question);
st.setString(3, exam.rep);
st.executeUpdate();
}