Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
servlets
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
Nahuel Mereles Rodriguez
servlets
Commits
08d1f158
Commit
08d1f158
authored
May 09, 2022
by
Nahuel Mereles Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sentencia cliente terminada
parent
bb365c60
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
160 additions
and
1 deletions
+160
-1
src/main/java/com/roshka/bootcamp/BD.java
+1
-0
src/main/java/com/roshka/bootcamp/Cliente.java
+57
-0
src/main/java/com/roshka/bootcamp/ClienteServlet.java
+40
-0
src/main/java/com/roshka/bootcamp/SentenciaInsert.java
+37
-0
src/main/webapp/index.jsp
+3
-1
src/main/webapp/inserteCliente.html
+22
-0
target/classes/com/roshka/bootcamp/BD.class
+0
-0
target/classes/com/roshka/bootcamp/Cliente.class
+0
-0
target/classes/com/roshka/bootcamp/ClienteServlet.class
+0
-0
target/classes/com/roshka/bootcamp/SentenciaInsert.class
+0
-0
No files found.
src/main/java/com/roshka/bootcamp/BD.java
View file @
08d1f158
...
...
@@ -43,6 +43,7 @@ public class BD extends HttpServlet {
String
apellido
=
rs
.
getString
(
"apellido"
);
int
cantidad
=
rs
.
getInt
(
"Cantidad_factura"
);
out
.
println
(
"----------------------------------------------"
);
out
.
println
(
"<p>NOMBRE = \\"
+
nombre
+
"</p>"
);
out
.
println
(
"<p>APELLIDO = \\"
+
apellido
+
"</p>"
);
out
.
println
(
"<p>CANTIDAD FACTURA = \\"
+
cantidad
+
"</p>"
);
...
...
src/main/java/com/roshka/bootcamp/Cliente.java
0 → 100644
View file @
08d1f158
package
com
.
roshka
.
bootcamp
;
public
class
Cliente
{
private
int
id
;
private
String
nombre
;
private
String
apellido
;
private
int
nro_cedula
;
private
String
telefono
;
public
Cliente
()
{
}
public
Cliente
(
String
nombre
,
String
apellido
,
int
nro_cedula
,
String
telefono
)
{
this
.
nombre
=
nombre
;
this
.
apellido
=
apellido
;
this
.
nro_cedula
=
nro_cedula
;
this
.
telefono
=
telefono
;
}
public
int
getId
()
{
return
id
;
}
public
String
getName
()
{
return
nombre
;
}
public
void
setName
(
String
name
)
{
this
.
nombre
=
name
;
}
public
String
getApellido
()
{
return
apellido
;
}
public
void
setApellido
(
String
apellido
)
{
this
.
apellido
=
apellido
;
}
public
int
getNro_cedula
()
{
return
nro_cedula
;
}
public
void
setNro_cedula
(
int
nro_cedula
)
{
this
.
nro_cedula
=
nro_cedula
;
}
public
String
getTelefono
()
{
return
telefono
;
}
public
void
setTelefono
(
String
telefono
)
{
this
.
telefono
=
telefono
;
}
}
src/main/java/com/roshka/bootcamp/ClienteServlet.java
0 → 100644
View file @
08d1f158
package
com
.
roshka
.
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
;
@WebServlet
(
"/inserteCliente"
)
public
class
ClienteServlet
extends
HttpServlet
{
@Override
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
int
status
=
0
;
resp
.
setContentType
(
"text/html"
);
PrintWriter
out
=
resp
.
getWriter
();
String
nombre
=
req
.
getParameter
(
"nombre"
);
String
apellido
=
req
.
getParameter
(
"apellido"
);
int
nro_cedula
=
Integer
.
parseInt
(
req
.
getParameter
(
"nro_cedula"
));
String
telefono
=
req
.
getParameter
(
"telefono"
);
Cliente
cliente
=
new
Cliente
(
nombre
,
apellido
,
nro_cedula
,
telefono
);
status
=
SentenciaInsert
.
insertCliente
(
cliente
);
if
(
status
>
0
){
out
.
print
(
"<p>Record saved successfully!</p>"
);
req
.
getRequestDispatcher
(
"index.jsp"
).
include
(
req
,
resp
);
}
else
{
out
.
println
(
"Sorry! unable to save record"
);
}
out
.
close
();
}
}
src/main/java/com/roshka/bootcamp/SentenciaInsert.java
0 → 100644
View file @
08d1f158
package
com
.
roshka
.
bootcamp
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
public
class
SentenciaInsert
{
static
Connection
getConnection
(){
Connection
con
=
null
;
try
{
Class
.
forName
(
"org.postgresql.Driver"
);
con
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5432/bootcamp_market"
,
"postgres"
,
"postgres"
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
e
);}
return
con
;
}
public
static
int
insertCliente
(
Cliente
cliente
){
int
status
=
0
;
try
{
Connection
con
=
SentenciaInsert
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"insert into Cliente(nombre,apellido,nro_cedula,telefono) values (?,?,?,?)"
);
ps
.
setString
(
1
,
cliente
.
getName
());
ps
.
setString
(
2
,
cliente
.
getApellido
());
ps
.
setInt
(
3
,
cliente
.
getNro_cedula
());
ps
.
setString
(
4
,
cliente
.
getTelefono
());
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();}
return
status
;
}
}
src/main/webapp/index.jsp
View file @
08d1f158
<html>
<body>
<h2>
Anda a alguna URL
</h2>
<a
href=
"./inserteCliente.html"
>
Inserte un cliente en la db
</a>
</body>
</html>
</html>
\ No newline at end of file
src/main/webapp/inserteCliente.html
0 → 100644
View file @
08d1f158
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Inserte Cliente
</title>
</head>
<body>
<form
method=
"post"
action=
"inserteCliente"
>
<label>
Nombre:
</label>
<input
type=
"text"
name=
"nombre"
><br/>
<label>
Apellido:
</label>
<input
type=
"text"
name=
"apellido"
><br/>
<label>
Numero de Cedula:
</label>
<input
type=
"number"
name=
"nro_cedula"
><br/>
<label>
Telefono:
</label>
<input
type=
"text"
name=
"telefono"
><br/>
<input
type=
"submit"
>
</form>
</body>
</html>
\ No newline at end of file
target/classes/com/roshka/bootcamp/BD.class
View file @
08d1f158
No preview for this file type
target/classes/com/roshka/bootcamp/Cliente.class
0 → 100644
View file @
08d1f158
File added
target/classes/com/roshka/bootcamp/ClienteServlet.class
0 → 100644
View file @
08d1f158
File added
target/classes/com/roshka/bootcamp/SentenciaInsert.class
0 → 100644
View file @
08d1f158
File added
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