Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
94489320
Commit
94489320
authored
Nov 11, 2025
by
Luna Riegel
Browse files
Refactor: Use Hikari connection pool in all queries
parent
c862f733
Changes
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/DatabaseHandler.java
View file @
94489320
...
...
@@ -41,8 +41,8 @@ public class DatabaseHandler {
try
{
// String jdbcurl = H2GISDBFactory.createDataSource(DB_NAME,
// true, ";AUTO_SERVER=TRUE").getConnection().getMetaData().getURL();
String
jdbcurl
=
H2GISDBFactory
.
createSpatialDataBase
(
DB_NAME
,
true
,
";AUTO_SERVER=TRUE"
).
getMetaData
().
getURL
();
logger
.
info
(
jdbcurl
);
logger
.
info
(
"2] {}"
,
jdbcurl
);
HikariDataSource
ds
=
new
HikariDataSource
();
ds
.
setJdbcUrl
(
jdbcurl
);
...
...
@@ -216,7 +216,7 @@ public class DatabaseHandler {
public
List
<
CityObject
>
getAllCityObjects
()
{
List
<
CityObject
>
cos
=
new
ArrayList
<>();
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)
))
{
try
(
Connection
con
=
dataSource
.
getConnection
(
))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid, bbox, data FROM features"
))
{
ResultSet
rs
=
ps
.
executeQuery
();
cos
.
addAll
(
retrieveCityObjects
(
rs
));
...
...
@@ -235,7 +235,7 @@ public class DatabaseHandler {
public
List
<
GmlId
>
getBufferIntersectingObjects
(
GmlId
gmlID
,
double
bufferSize
)
{
List
<
GmlId
>
intersectingObjects
=
new
ArrayList
<>();
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)
))
{
try
(
Connection
con
=
dataSource
.
getConnection
(
))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid FROM features AS tab1"
+
" WHERE ST_INTERSECTS(ST_BUFFER(tab1.bbox,?), (SELECT bbox FROM features WHERE gmlid = ?)) "
+
"AND tab1.gmlid <> ?"
))
{
...
...
@@ -261,7 +261,7 @@ public class DatabaseHandler {
public
List
<
GmlId
>
getBBoxIntersectingObjects
(
GmlId
id
)
{
List
<
GmlId
>
intersectingObjects
=
new
ArrayList
<>();
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)
))
{
try
(
Connection
con
=
dataSource
.
getConnection
(
))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT gmlid FROM features AS tab1"
+
" WHERE ST_INTERSECTS(tab1.bbox, (SELECT bbox FROM features WHERE gmlid = ?)) AND tab1.gmlid <> ?"
))
{
...
...
@@ -283,7 +283,7 @@ public class DatabaseHandler {
public
int
getFeatureCount
()
{
int
count
=
-
1
;
try
(
Connection
con
=
new
ConnectionWrapper
(
H2GISDBFactory
.
openSpatialDataBase
(
DB_NAME
)
))
{
try
(
Connection
con
=
dataSource
.
getConnection
(
))
{
try
(
PreparedStatement
ps
=
con
.
prepareStatement
(
"SELECT COUNT(gmlid) AS nr FROM features"
))
{
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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