You need to sign in or sign up before continuing.
Commit 3e42a461 by Jose Baez

Merge branch 'sendemail3' into 'develop'

Arreglando errores traidos del pull

See merge request !39
parents 4b3ad9a6 e10e05ae
......@@ -17,9 +17,9 @@ public class EditServlet extends HttpServlet {
int id = Integer.parseInt(request.getParameter("id"));
ProfesorDao profesorDao = new ProfesorDao();
// Profesor profesor = profesorDao.getProfesorById(id);
Profesor profesor = profesorDao.getProfesorById(id);
// request.setAttribute("Profesor", profesor);
request.setAttribute("Profesor", profesor);
RequestDispatcher rd = request.getRequestDispatcher("formulario_profesor.jsp");
rd.include(request, response);
}
......@@ -36,13 +36,13 @@ public class EditServlet extends HttpServlet {
Profesor profesor =new Profesor(nro_cedula, nombre, apellido, email);
profesor.setId(id);
// int status=ProfesorDao.update(profesor);
int status=ProfesorDao.update(profesor);
// if(status>0){
// response.sendRedirect("formulario_profesor.jsp");
// }else{
// System.out.println("Sorry! unable to update record");
// }
if(status>0){
response.sendRedirect("formulario_profesor.jsp");
}else{
System.out.println("Sorry! unable to update record");
}
}
}
......@@ -80,6 +80,49 @@ public class ProfesorDao {
}
return profesores;
}
public static int update(Profesor p){
int status=0;
try{
Connection con= DataBase.getConnection();
PreparedStatement ps=con.prepareStatement(
"update profesor set nombre=?, apellido=?, correo=?, nro_cedula=? where id=?");
ps.setString(1,p.getNombre());
ps.setString(2,p.getApellido());
ps.setString(3,p.getCorreo());
ps.setInt(4,p.getNro_cedula());
ps.setInt(5,p.getId());
status=ps.executeUpdate();
con.close();
}catch(Exception ex){ex.printStackTrace();}
return status;
}
public static Profesor getProfesorById(int id){
Profesor profesor=new Profesor();
try{
Connection con=DataBase.getConnection();
PreparedStatement ps=con.prepareStatement("select * from profesor where id=?");
ps.setInt(1,id);
ResultSet rs=ps.executeQuery();
if(rs.next()){
profesor.setId(rs.getInt(1));
profesor.setNombre(rs.getString(2));
profesor.setApellido(rs.getString(3));
profesor.setNro_cedula(rs.getInt(4));
profesor.setCorreo(rs.getString(5));
}
con.close();
}catch(Exception ex){ex.printStackTrace();}
return profesor;
}
public static int delete(int id){
int status=0;
try{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment