Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_dzienna_15_09
Commits
8ef637ef
Commit
8ef637ef
authored
Sep 27, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wypisywanie również job_id
parent
0c1ef046
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
Odczyt2.java
...-BazyDanych/src/main/java/zajecia/postgresql/Odczyt2.java
+3
-2
No files found.
PC24-BazyDanych/src/main/java/zajecia/postgresql/Odczyt2.java
View file @
8ef637ef
...
@@ -17,15 +17,16 @@ public class Odczyt2 {
...
@@ -17,15 +17,16 @@ public class Odczyt2 {
// - Podajemy nazwy kolumn, a nie numery.
// - Podajemy nazwy kolumn, a nie numery.
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
(
Connection
c
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5432/hr"
,
"kurs"
,
"abc123"
);
try
(
Connection
c
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5432/hr"
,
"kurs"
,
"abc123"
);
PreparedStatement
stmt
=
c
.
prepareStatement
(
"SELECT * FROM employees"
);
PreparedStatement
stmt
=
c
.
prepareStatement
(
"SELECT * FROM employees
ORDER BY employee_id
"
);
ResultSet
rs
=
stmt
.
executeQuery
())
{
ResultSet
rs
=
stmt
.
executeQuery
())
{
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
int
id
=
rs
.
getInt
(
"employee_id"
);
int
id
=
rs
.
getInt
(
"employee_id"
);
String
firstName
=
rs
.
getString
(
"first_name"
);
String
firstName
=
rs
.
getString
(
"first_name"
);
String
lastName
=
rs
.
getString
(
"last_name"
);
String
lastName
=
rs
.
getString
(
"last_name"
);
String
jobId
=
rs
.
getString
(
"job_id"
);
BigDecimal
salary
=
rs
.
getBigDecimal
(
"salary"
);
BigDecimal
salary
=
rs
.
getBigDecimal
(
"salary"
);
System
.
out
.
println
(
"Pracownik nr "
+
id
+
": "
+
firstName
+
" "
+
lastName
+
" zarabia "
+
salary
);
System
.
out
.
println
(
"Pracownik nr "
+
id
+
": "
+
firstName
+
" "
+
lastName
+
"
("
+
jobId
+
")
zarabia "
+
salary
);
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
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