Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
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_20230928
Commits
eba5201d
Commit
eba5201d
authored
Sep 29, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pierwszy program JDBC
parent
ec39bc57
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
pom.xml
PC23-BazyDanych/pom.xml
+8
-0
OdczytajOsoby.java
PC23-BazyDanych/src/main/java/zajecia/OdczytajOsoby.java
+32
-0
No files found.
PC23-BazyDanych/pom.xml
View file @
eba5201d
...
@@ -11,4 +11,12 @@
...
@@ -11,4 +11,12 @@
<maven.compiler.target>
17
</maven.compiler.target>
<maven.compiler.target>
17
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
</properties>
<dependencies>
<dependency>
<groupId>
org.postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
<version>
42.6.0
</version>
</dependency>
</dependencies>
</project>
</project>
PC23-BazyDanych/src/main/java/zajecia/OdczytajOsoby.java
0 → 100644
View file @
eba5201d
package
zajecia
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
public
class
OdczytajOsoby
{
public
static
void
main
(
String
[]
args
)
{
// JDBC - Java Databse Connectivity
String
url
=
"jdbc:postgresql://localhost/kurs"
;
try
{
Connection
c
=
DriverManager
.
getConnection
(
url
,
"kurs"
,
"abc123"
);
System
.
out
.
println
(
"Udało się połączyć. c = "
+
c
);
Statement
stmt
=
c
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"SELECT * FROM osoby"
);
while
(
rs
.
next
())
{
String
imie
=
rs
.
getString
(
"imie"
);
String
nazwisko
=
rs
.
getString
(
"nazwisko"
);
System
.
out
.
println
(
imie
+
" "
+
nazwisko
);
}
rs
.
close
();
stmt
.
close
();
c
.
close
();
}
catch
(
SQLException
e
)
{
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