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
27b3f24e
Commit
27b3f24e
authored
May 12, 2022
by
Yovan Martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trabajando validacion de correo
parent
74ceb612
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
0 deletions
+127
-0
src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java
+33
-0
src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java
+94
-0
No files found.
src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java
0 → 100644
View file @
27b3f24e
package
com
.
roshka
.
proyectofinal
.
Postulante
;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Postulante
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
public
class
PostulanteDao
{
public
static
int
save
(
Postulante
postulante
){
int
status
=
0
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"insert into postulante(nombre,apellido,nro_cedula,correo,telefono,direccion,experiencia_laboral,estudio_universitario,notebook,bootcamp_id,aceptado) values (?,?,?,?,?,?,?,?,?,?,?)"
);
ps
.
setString
(
1
,
postulante
.
getNombre
());
ps
.
setString
(
2
,
postulante
.
getApellido
());
ps
.
setInt
(
3
,
postulante
.
getNro_cedula
());
ps
.
setString
(
4
,
postulante
.
getCorreo
());
ps
.
setString
(
5
,
postulante
.
getTelefono
());
ps
.
setString
(
6
,
postulante
.
getDireccion
());
ps
.
setBoolean
(
7
,
postulante
.
getExpLaboral
());
ps
.
setBoolean
(
8
,
postulante
.
getEstudioUniversitario
());
ps
.
setBoolean
(
9
,
postulante
.
getNotebook
());
ps
.
setInt
(
10
,
postulante
.
getBootcampId
());
ps
.
setBoolean
(
11
,
postulante
.
getAceptado
());
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();}
return
status
;
}
}
src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java
0 → 100644
View file @
27b3f24e
package
com
.
roshka
.
proyectofinal
.
Postulante
;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Postulante
;
import
com.roshka.proyectofinal.entity.Bootcamp
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
@WebServlet
(
"/SaveServlet"
)
public
class
SaveServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/html"
);
PrintWriter
out
=
response
.
getWriter
();
boolean
correoRepetido
=
false
;
try
{
Connection
con
=
DataBase
.
getConnection
();
//
Statement
stmt
=
con
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"SELECT correo FROM postulante;"
);
//
String
nombre
=
request
.
getParameter
(
"nombre"
);
String
apellido
=
request
.
getParameter
(
"apellido"
);
int
cedula
=
Integer
.
parseInt
(
request
.
getParameter
(
"cedula"
));
String
correo
=
request
.
getParameter
(
"correo"
);
while
(
rs
.
next
()){
String
correoBase
=
rs
.
getString
(
"correo"
);
if
(
correo
.
equals
(
correo
)){
correoRepetido
=
true
;
}
}
String
telefono
=
request
.
getParameter
(
"telefono"
);
String
direccion
=
request
.
getParameter
(
"direccion"
);
boolean
experienciaProgramando
=
false
;
boolean
experienciaLaboral
=
false
;
boolean
universidad
=
false
;
boolean
notebook
=
false
;
if
(
request
.
getParameter
(
"experiencia_laboral"
)
!=
null
){
experienciaLaboral
=
true
;
}
if
(
request
.
getParameter
(
"experiencia_programando"
)
!=
null
)
{
experienciaProgramando
=
true
;
}
if
(
request
.
getParameter
(
"notebook"
)
!=
null
){
notebook
=
true
;
}
if
(
request
.
getParameter
(
"universidad"
)
!=
null
){
universidad
=
true
;
}
if
(!
correoRepetido
){
Bootcamp
bootcamp
=
new
Bootcamp
();
Postulante
postulante
=
new
Postulante
();
postulante
.
setNombre
(
nombre
);
postulante
.
setApellido
(
apellido
);
postulante
.
setNro_cedula
(
cedula
);
postulante
.
setCorreo
(
correo
);
postulante
.
setTelefono
(
telefono
);
postulante
.
setDireccion
(
direccion
);
postulante
.
setExpLaboral
(
experienciaLaboral
);
postulante
.
setEstudioUniversitario
(
universidad
);
postulante
.
setNotebook
(
notebook
);
postulante
.
setBootcampId
(
1
);
postulante
.
setAceptado
(
false
);
int
status
=
PostulanteDao
.
save
(
postulante
);
if
(
status
>
0
){
out
.
print
(
"<p>Record saved successfully!</p>"
);
request
.
getRequestDispatcher
(
"index.html"
).
include
(
request
,
response
);
}
else
{
out
.
println
(
"Sorry! unable to save record"
);
}
}
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();}
out
.
close
();
}
}
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