Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ProyectoFinal-Bootcamp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jose Baez
ProyectoFinal-Bootcamp
Commits
e10e05ae
Commit
e10e05ae
authored
May 17, 2022
by
Nahuel Mereles Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arreglando errores traidos del pull
parent
eb7dcb21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
8 deletions
+51
-8
src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java
+8
-8
src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java
+43
-0
No files found.
src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java
View file @
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"
);
}
}
}
src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java
View file @
e10e05ae
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment