Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20230403
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
20230403
Commits
7ceaa977
Commit
7ceaa977
authored
Apr 04, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Przeniesienie katalogu sql do projektu BazyDanych
parent
c59202d2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
21 additions
and
2 deletions
+21
-2
0-admin.sql
PC22-BazyDanych_Wstep/sql/hr-postgresql/0-admin.sql
+0
-0
1-hr-create-tabele.sql
...BazyDanych_Wstep/sql/hr-postgresql/1-hr-create-tabele.sql
+0
-0
2-hr-create-dodatki.sql
...azyDanych_Wstep/sql/hr-postgresql/2-hr-create-dodatki.sql
+0
-0
3-hr-insert.sql
PC22-BazyDanych_Wstep/sql/hr-postgresql/3-hr-insert.sql
+0
-0
4-hr-moje-dodatki.sql
...-BazyDanych_Wstep/sql/hr-postgresql/4-hr-moje-dodatki.sql
+0
-0
9-hr-drop.sql
PC22-BazyDanych_Wstep/sql/hr-postgresql/9-hr-drop.sql
+0
-0
wgraj_hr.bat
PC22-BazyDanych_Wstep/sql/hr-postgresql/wgraj_hr.bat
+0
-0
wgraj_hr.sql
PC22-BazyDanych_Wstep/sql/hr-postgresql/wgraj_hr.sql
+0
-0
ProsteZapytanie1.java
...-BazyDanych_Wstep/src/bazy/podstawy/ProsteZapytanie1.java
+21
-2
No files found.
PC2
1-Watki
/sql/hr-postgresql/0-admin.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/0-admin.sql
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/1-hr-create-tabele.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/1-hr-create-tabele.sql
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/2-hr-create-dodatki.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/2-hr-create-dodatki.sql
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/3-hr-insert.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/3-hr-insert.sql
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/4-hr-moje-dodatki.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/4-hr-moje-dodatki.sql
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/9-hr-drop.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/9-hr-drop.sql
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/wgraj_hr.bat
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/wgraj_hr.bat
View file @
7ceaa977
File moved
PC2
1-Watki
/sql/hr-postgresql/wgraj_hr.sql
→
PC2
2-BazyDanych_Wstep
/sql/hr-postgresql/wgraj_hr.sql
View file @
7ceaa977
File moved
PC22-BazyDanych_Wstep/src/bazy/podstawy/ProsteZapytanie1.java
View file @
7ceaa977
package
bazy
.
podstawy
;
package
bazy
.
podstawy
;
import
java.math.BigDecimal
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
public
class
ProsteZapytanie1
{
public
class
ProsteZapytanie1
{
// JDBC - Java Database Connectivity
// JDBC - Java Database Connectivity
// Programista w swoim kodzie używa ogólnych in
s
terfejsów i operacji:
// Programista w swoim kodzie używa ogólnych interfejsów i operacji:
// Connection, PreparedStatement, ResultSet, executeQuery...
// Connection, PreparedStatement, ResultSet, executeQuery...
// natomiast ich implementacje są dostarczane w formie "sterowników" właściwych dla poszczególnych rodzajów baz danych.
// natomiast ich implementacje są dostarczane w formie "sterowników" właściwych dla poszczególnych rodzajów baz danych.
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
{
try
{
// Koncepcyjnie rzecz biorąc, robimy coś takiego, ale zapisuje się to ogólnie...
// Connection c = new PGConnection(...);
Connection
c
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost/hr"
,
"kurs"
,
"abc123"
);
Connection
c
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost/hr"
,
"kurs"
,
"abc123"
);
System
.
out
.
println
(
"Udało się połączyć. Połączenie: "
+
c
);
System
.
out
.
println
(
"Udało się połączyć. Połączenie: "
+
c
);
PreparedStatement
stmt
=
c
.
prepareStatement
(
"SELECT * FROM employees"
);
ResultSet
rs
=
stmt
.
executeQuery
();
System
.
out
.
println
(
"Mam wyniki: "
+
rs
);
while
(
rs
.
next
())
{
int
id
=
rs
.
getInt
(
1
);
// kolumna wynikowa nr 1 - numeracja od 1!
String
imie
=
rs
.
getString
(
2
);
// kolumna nr 2
// ale wartości można też odczytywać podając nazwę kolumny:
String
nazwisko
=
rs
.
getString
(
"last_name"
);
String
job
=
rs
.
getString
(
"job_id"
);
BigDecimal
pensja
=
rs
.
getBigDecimal
(
"salary"
);
java
.
sql
.
Date
data
=
rs
.
getDate
(
"hire_date"
);
System
.
out
.
printf
(
"%d. %s %s (%s) zatr. %s zarabia %s\n"
,
id
,
imie
,
nazwisko
,
job
,
data
,
pensja
);
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
// Connection c = new PGConnection();
}
}
...
...
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