Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isochrone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institut für Informatik
dbis
dbis-isochrone
isochrone
Commits
4228229f
"README.md" did not exist on "610e98fdb2d5f9977d79bf6bba1dda484f9d2dc5"
Commit
4228229f
authored
10 years ago
by
Nikolaus Krismer
Browse files
Options
Downloads
Patches
Plain Diff
reworked initConnection (and getConnection methods)
parent
9b4ec141
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/unibz/inf/isochrone/db/Database.java
+22
-11
22 additions, 11 deletions
src/main/java/it/unibz/inf/isochrone/db/Database.java
with
22 additions
and
11 deletions
src/main/java/it/unibz/inf/isochrone/db/Database.java
+
22
−
11
View file @
4228229f
...
@@ -632,32 +632,43 @@ public class Database {
...
@@ -632,32 +632,43 @@ public class Database {
// FIXME: Find a fix for prepared statements with parameters
// FIXME: Find a fix for prepared statements with parameters
// (we should NOT set strings in preparedStatemens just because we want to cache something)
// (we should NOT set strings in preparedStatemens just because we want to cache something)
protected
PreparedStatement
getPstmt
(
final
String
query
)
{
protected
PreparedStatement
getPstmt
(
final
String
query
)
{
initConnection
();
if
(
pstmtsCacheMap
==
null
)
{
if
(
pstmtsCacheMap
==
null
)
{
pstmtsCacheMap
=
new
HashMap
<>();
pstmtsCacheMap
=
new
HashMap
<>();
}
}
PreparedStatement
pstmt
=
pstmtsCacheMap
.
get
(
query
);
try
{
try
{
if
(
pstmt
sCacheMap
.
containsKey
(
query
)
&&
!
pstmtsCacheMap
.
get
(
query
)
.
isClosed
())
{
if
(
pstmt
!=
null
&&
!
pstmt
.
isClosed
())
{
return
pstmt
sCacheMap
.
get
(
query
)
;
return
pstmt
;
}
}
final
PreparedStatement
pstmt
=
connection
.
prepareStatement
(
query
);
pstmt
=
getConnection
().
prepareStatement
(
query
);
pstmtsCacheMap
.
put
(
query
,
pstmt
);
return
pstmt
;
}
catch
(
final
SQLException
e
)
{
}
catch
(
final
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
pstmt
=
null
;
}
}
return
null
;
if
(
pstmt
!=
null
)
{
}
pstmtsCacheMap
.
put
(
query
,
pstmt
);
}
protected
void
initConnection
()
{
return
pstmt
;
connection
=
ConfigIsochrone
.
getInstance
().
getConnection
();
}
}
protected
Connection
getConnection
()
{
protected
Connection
getConnection
()
{
initConnection
();
if
(
connection
==
null
)
{
connection
=
ConfigIsochrone
.
getInstance
().
getConnection
();
}
else
{
try
{
if
(
connection
.
isClosed
())
{
connection
=
ConfigIsochrone
.
getInstance
().
getConnection
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
connection
=
null
;
}
}
return
connection
;
return
connection
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment