Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SkuciSe
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
Tim 2 - 2022
SkuciSe
Commits
8e8325f5
Commit
8e8325f5
authored
Sep 02, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lokacija i database
parent
c799f62f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
0 deletions
+94
-0
SkuciSe/src/main/java/com/example/SkuciSe/model/lokacija/Lokacija.java
+16
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/DataBase.java
+24
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/LokacijaRepository.java
+54
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/model/lokacija/Lokacija.java
0 → 100644
View file @
8e8325f5
package
com
.
example
.
SkuciSe
.
model
.
lokacija
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public
class
Lokacija
{
int
lokacijaId
;
String
naziv
;
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/DataBase.java
0 → 100644
View file @
8e8325f5
package
com
.
example
.
SkuciSe
.
repository
;
import
org.springframework.stereotype.Component
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
@Component
public
class
DataBase
{
Connection
connection
=
null
;
Statement
statement
=
null
;
public
DataBase
()
{
try
{
connection
=
DriverManager
.
getConnection
(
"jdbc:mariadb://localhost/skucise"
,
"root"
,
""
);
statement
=
connection
.
createStatement
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/LokacijaRepository.java
0 → 100644
View file @
8e8325f5
package
com
.
example
.
SkuciSe
.
repository
;
import
com.example.SkuciSe.model.lokacija.Lokacija
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
@Component
public
class
LokacijaRepository
{
@Autowired
DataBase
dataBase
;
public
List
<
Lokacija
>
findAll
()
{
String
sql
=
"select * from lokacija"
;
List
<
Lokacija
>
list
=
new
ArrayList
<
Lokacija
>();
ResultSet
rs
=
null
;
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
list
.
add
(
new
Lokacija
(
rs
.
getInt
(
"lokacijaid"
),
rs
.
getString
(
"naziv"
)));
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
list
;
}
public
Lokacija
findById
(
int
lokacijaId
)
{
String
sql
=
"select * from lokacija where lokacijaid = "
+
lokacijaId
;
ResultSet
rs
=
null
;
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
return
new
Lokacija
(
rs
.
getInt
(
"lokacijaid"
),
rs
.
getString
(
"naziv"
));
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
null
;
}
}
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