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
Oscar Enrique Gonzalez Escurra
servlets
Commits
10224579
Commit
10224579
authored
Feb 22, 2024
by
Oscar Enrique Gonzalez Escurra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consulta SQL en jsp
parent
70c9aa14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
src/main/webapp/consultajsp.jsp
+62
-0
No files found.
src/main/webapp/consultajsp.jsp
0 → 100644
View file @
10224579
<
%@
page
import=
"java.sql.*"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<html>
<head>
<title>
Consulta
</title>
</head>
<body>
<
%
Connection
connection =
null;
try
{
Class
.
forName
("
org
.
postgresql
.
Driver
");
connection =
DriverManager
.
getConnection
("
jdbc:postgresql:
//
localhost:5432
/
bootcamp_market
",
"
postgres
",
"
postgres
");
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
err
.
println
(
e
.
getClass
().
getName
()
+
"
:
"
+
e
.
getMessage
());
System
.
exit
(
0
);
}
try
{
Statement
stmt =
connection.createStatement();
ResultSet
rs =
stmt.executeQuery("select
a
.
nombre
,
apellido
,
count
(
b
.
cliente_id
)
Cantidad_factura
from
cliente
a
"
+
"
inner
join
factura
b
"
+
"
on
a
.
id=
b.cliente_id
"
+
"
group
by
a
.
nombre
,
a
.
apellido
"
+
"
order
by
Cantidad_factura
desc
;");
%
>
<table
border=
"1"
>
<tr>
<th>
Nombre
</th>
<th>
Apellido
</th>
<th>
Cantidad de Facturas
</th>
</tr>
<
%
while
(
rs
.
next
())
{
String
nombre =
rs.getString("nombre");
String
apellido =
rs.getString("apellido");
int
cantidad =
rs.getInt("Cantidad_factura");
%
>
<tr>
<td><
%=
nombre
%
></td>
<td><
%=
apellido
%
></td>
<td><
%=
cantidad
%
></td>
</tr>
<
%
}
rs
.
close
();
stmt
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
connection
!=
null
)
{
try
{
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
%
>
</table>
</body>
</html>
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