Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
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
javab_20230617
Commits
a8bf750e
Commit
a8bf750e
authored
Jun 18, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dodanie sterownika JDBC i druga wersja odczytu z bazy
parent
abcfbbfb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
.classpath
PC21-JavaUzupelnienia/.classpath
+1
-0
postgresql-42.6.0.jar
PC21-JavaUzupelnienia/postgresql-42.6.0.jar
+0
-0
Odczyt2.java
PC21-JavaUzupelnienia/src/bazy/na_zywo/Odczyt2.java
+24
-0
No files found.
PC21-JavaUzupelnienia/.classpath
View file @
a8bf750e
...
...
@@ -6,5 +6,6 @@
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"lib"
path=
"postgresql-42.6.0.jar"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
PC21-JavaUzupelnienia/postgresql-42.6.0.jar
0 → 100644
View file @
a8bf750e
File added
PC21-JavaUzupelnienia/src/bazy/na_zywo/Odczyt2.java
0 → 100644
View file @
a8bf750e
package
bazy
.
na_zywo
;
import
java.sql.*
;
public
class
Odczyt2
{
public
static
void
main
(
String
[]
args
)
{
String
url
=
"jdbc:postgresql://localhost:5432/postgres"
;
try
(
Connection
c
=
DriverManager
.
getConnection
(
url
,
"postgres"
,
"abc123"
);
PreparedStatement
stmt
=
c
.
prepareStatement
(
"SELECT * FROM osoby"
);
ResultSet
rs
=
stmt
.
executeQuery
())
{
while
(
rs
.
next
())
{
System
.
out
.
printf
(
"Osoba nr %d to jest %s %s, ur. %s, zarabia %s%n"
,
rs
.
getInt
(
"id"
),
rs
.
getString
(
"imie"
),
rs
.
getString
(
"nazwisko"
),
rs
.
getString
(
"data_urodzenia"
),
rs
.
getBigDecimal
(
"pensja"
));
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
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