Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
histream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Raphael
histream
Commits
5e0a72e2
Commit
5e0a72e2
authored
Jan 18, 2017
by
R.W.Majeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed duplicate and to early close of database connection
parent
6693f118
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
histream-i2b2/src/main/java/de/sekmi/histream/i2b2/I2b2Extractor.java
...2/src/main/java/de/sekmi/histream/i2b2/I2b2Extractor.java
+15
-6
histream-i2b2/src/main/java/de/sekmi/histream/i2b2/I2b2ExtractorFactory.java
...ain/java/de/sekmi/histream/i2b2/I2b2ExtractorFactory.java
+13
-4
No files found.
histream-i2b2/src/main/java/de/sekmi/histream/i2b2/I2b2Extractor.java
View file @
5e0a72e2
...
...
@@ -4,8 +4,8 @@ import java.math.BigDecimal;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Timestamp
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
de.sekmi.histream.AbnormalFlag
;
...
...
@@ -244,11 +244,20 @@ public class I2b2Extractor implements ObservationSupplier {
}
@Override
public
void
close
()
throws
SQLException
{
Statement
st
=
rs
.
getStatement
();
rs
.
close
();
st
.
close
();
dbc
.
close
();
public
void
close
()
{
log
.
info
(
"Closing extractor "
+
this
.
toString
());
// Statement st = rs.getStatement();
try
{
rs
.
close
();
}
catch
(
SQLException
e
){
log
.
log
(
Level
.
WARNING
,
"Failed to close recortset"
,
e
);
}
// st.close();
try
{
dbc
.
close
();
}
catch
(
SQLException
e
){
log
.
log
(
Level
.
WARNING
,
"Failed to close connection"
,
e
);
}
}
public
void
dump
()
throws
SQLException
{
...
...
histream-i2b2/src/main/java/de/sekmi/histream/i2b2/I2b2ExtractorFactory.java
View file @
5e0a72e2
...
...
@@ -97,11 +97,16 @@ public class I2b2ExtractorFactory implements AutoCloseable, ObservationExtractor
}
private
void
createTemporaryConceptTable
(
Connection
dbc
,
Iterable
<
String
>
concepts
)
throws
SQLException
{
// delete table if previously existing
try
(
Statement
s
=
dbc
.
createStatement
()
){
s
.
executeUpdate
(
"DROP TABLE IF EXISTS temp_concepts"
);
}
try
(
Statement
s
=
dbc
.
createStatement
()
){
s
.
executeUpdate
(
"CREATE TEMPORARY TABLE temp_concepts(concept VARCHAR(255) PRIMARY KEY)"
);
}
try
(
PreparedStatement
ps
=
dbc
.
prepareStatement
(
"INSERT INTO temp_concepts(concept) VALUES(?)"
)
){
// TODO do we need to make sure that there are no duplicate concepts???
for
(
String
concept
:
concepts
){
ps
.
clearParameters
();
ps
.
clearWarnings
();
...
...
@@ -139,8 +144,10 @@ public class I2b2ExtractorFactory implements AutoCloseable, ObservationExtractor
// TODO move connection and prepared statement to I2b2Extractor
PreparedStatement
ps
=
null
;
ResultSet
rs
=
null
;
try
(
Connection
dbc
=
ds
.
getConnection
()
){
dbc
.
setAutoCommit
(
false
);
Connection
dbc
=
null
;
try
{
// no try with resource, because we need to pass the connection to the extractor
dbc
=
ds
.
getConnection
();
dbc
.
setAutoCommit
(
true
);
StringBuilder
b
=
new
StringBuilder
(
600
);
b
.
append
(
"SELECT "
);
b
.
append
(
SELECT_PARAMETERS
+
" FROM "
+
SELECT_TABLE
+
" "
);
...
...
@@ -171,14 +178,13 @@ public class I2b2ExtractorFactory implements AutoCloseable, ObservationExtractor
b
.
append
(
"WHERE f.start_date BETWEEN ? AND ? "
);
b
.
append
(
SELECT_ORDER_GROUP
);
log
.
info
(
"SQL: "
+
b
.
toString
());
ps
=
prepareStatement
(
dbc
,
b
.
toString
());
ps
.
setTimestamp
(
1
,
start_min
);
ps
.
setTimestamp
(
2
,
start_max
);
rs
=
ps
.
executeQuery
();
return
new
I2b2Extractor
(
this
,
dbc
,
rs
);
}
catch
(
SQLException
e
){
// XXX maybe we don't need to do this, since the connection is closed anyway
// clean up
if
(
rs
!=
null
){
rs
.
close
();
...
...
@@ -186,6 +192,9 @@ public class I2b2ExtractorFactory implements AutoCloseable, ObservationExtractor
if
(
ps
!=
null
){
ps
.
close
();
}
if
(
dbc
!=
null
){
dbc
.
close
();
}
throw
e
;
}
}
...
...
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