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
Adal Montania
servlets
Commits
faa5b115
Commit
faa5b115
authored
2 years ago
by
OscarGonzalez97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
se agregan parametros iniciales
parent
594dd0d1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
src/main/java/com/roshka/bootcamp/BD.java
+14
-8
No files found.
src/main/java/com/roshka/bootcamp/BD.java
View file @
faa5b115
package
com
.
roshka
.
bootcamp
;
package
com
.
roshka
.
bootcamp
;
import
jakarta.servlet.ServletConfig
;
import
jakarta.servlet.annotation.WebInitParam
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletRequest
;
...
@@ -8,18 +10,22 @@ import jakarta.servlet.http.HttpServletResponse;
...
@@ -8,18 +10,22 @@ import jakarta.servlet.http.HttpServletResponse;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.sql.*
;
import
java.sql.*
;
@WebServlet
(
"/conexion"
)
@WebServlet
(
urlPatterns
=
"/conexion"
,
initParams
=
{
@WebInitParam
(
name
=
"dbUrl"
,
value
=
"jdbc:postgresql://localhost:5432/bootcamp_market"
),
@WebInitParam
(
name
=
"dbUser"
,
value
=
"postgres"
),
@WebInitParam
(
name
=
"dbPassword"
,
value
=
"postgres"
),
})
public
class
BD
extends
HttpServlet
{
public
class
BD
extends
HttpServlet
{
Connection
connection
;
Connection
connection
;
public
void
init
()
{
public
void
init
(
ServletConfig
config
)
{
try
{
try
{
Class
.
forName
(
"org.postgresql.Driver"
);
Class
.
forName
(
"org.postgresql.Driver"
);
connection
=
DriverManager
connection
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5432/bootcamp_market"
,
.
getConnection
(
config
.
getInitParameter
(
"dbUrl"
),
config
.
getInitParameter
(
"dbUser"
),
config
.
getInitParameter
(
"dbPassword"
));
"postgres"
,
"postgres"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
System
.
err
.
println
(
e
.
getClass
().
getName
()
+
": "
+
e
.
getMessage
());
System
.
err
.
println
(
e
.
getClass
().
getName
()
+
": "
+
e
.
getMessage
());
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
}
}
...
@@ -43,9 +49,9 @@ public class BD extends HttpServlet {
...
@@ -43,9 +49,9 @@ public class BD extends HttpServlet {
String
apellido
=
rs
.
getString
(
"apellido"
);
String
apellido
=
rs
.
getString
(
"apellido"
);
int
cantidad
=
rs
.
getInt
(
"Cantidad_factura"
);
int
cantidad
=
rs
.
getInt
(
"Cantidad_factura"
);
out
.
println
(
"<p>NOMBRE =
\\
"
+
nombre
+
"</p>"
);
out
.
println
(
"<p>NOMBRE = "
+
nombre
+
"</p>"
);
out
.
println
(
"<p>APELLIDO =
\\
"
+
apellido
+
"</p>"
);
out
.
println
(
"<p>APELLIDO = "
+
apellido
+
"</p>"
);
out
.
println
(
"<p>CANTIDAD FACTURA =
\\
"
+
cantidad
+
"</p>"
);
out
.
println
(
"<p>CANTIDAD FACTURA = "
+
cantidad
+
"</p>"
);
}
}
out
.
println
(
"</body>"
);
out
.
println
(
"</body>"
);
...
...
This diff is collapsed.
Click to expand it.
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