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
a69cad26
Commit
a69cad26
authored
Jan 19, 2026
by
Luna Riegel
Browse files
Refactor: Cleanup Code
parent
311c4372
Pipeline
#12319
passed with stage
in 2 minutes and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/database/EmbeddedDatabaseHandler.java
View file @
a69cad26
...
...
@@ -48,7 +48,7 @@ public class EmbeddedDatabaseHandler {
String
jdbcUrl
;
try
{
if
(
config
.
inMemoryMode
())
{
jdbcUrl
=
setupInMemory
DataBase
(
config
.
getInMemoryH2Url
());
jdbcUrl
=
createEmbedded
DataBase
(
config
.
getInMemoryH2Url
());
}
else
if
(
config
.
tempFileMode
()){
Path
tmpDir
=
Files
.
createTempDirectory
(
config
.
databaseDirectory
());
tmpDir
.
toFile
().
deleteOnExit
();
...
...
@@ -67,7 +67,7 @@ public class EmbeddedDatabaseHandler {
if
(
config
.
attemptFallback
()){
logger
.
info
(
"Attempting fallback to in-memory database"
);
try
{
jdbcUrl
=
setupInMemory
DataBase
(
config
.
getFallbackH2Url
());
jdbcUrl
=
createEmbedded
DataBase
(
config
.
getFallbackH2Url
());
}
catch
(
Exception
e1
)
{
throw
new
EmbeddedDatabaseHandlerException
(
"Fallback to in-memory database failed, embedded database could not be created"
,
e1
);
}
...
...
@@ -93,19 +93,9 @@ public class EmbeddedDatabaseHandler {
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
ds:
:
close
));
}
// Embedded database can only ever be accessed by the local machine, suppress linter-warning about password leak
@SuppressWarnings
(
"java:S6437"
)
private
String
createEmbeddedDataBase
(
String
dbUrl
)
throws
SQLException
{
// DataSource source = H2GISDBFactory.createDataSource("file://"+dbUrl,
// true, config.getH2ParametersSuffix());
// try (Connection con = source.getConnection()) {
// return con.getMetaData().getURL();
// }
try
(
Connection
con
=
DriverManager
.
getConnection
(
dbUrl
,
"sa"
,
"sa"
)){
H2GISFunctions
.
load
(
con
);
return
con
.
getMetaData
().
getURL
();
}
}
private
String
setupInMemoryDataBase
(
String
dbUrl
)
throws
SQLException
{
try
(
Connection
con
=
DriverManager
.
getConnection
(
dbUrl
,
"sa"
,
"sa"
)){
H2GISFunctions
.
load
(
con
);
return
con
.
getMetaData
().
getURL
();
...
...
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