6
6
import java .io .IOException ;
7
7
import java .io .ObjectInputStream ;
8
8
import java .sql .Connection ;
9
+ import java .sql .PreparedStatement ;
9
10
import java .sql .ResultSet ;
10
11
import java .sql .SQLException ;
11
12
import java .util .Iterator ;
@@ -38,8 +39,9 @@ abstract class MapReducerJdbc<X> extends MapReducer<X> implements CancelableProc
38
39
}
39
40
40
41
// copy constructor
41
- MapReducerJdbc (MapReducerJdbc obj ) {
42
- super (obj );
42
+ MapReducerJdbc (MapReducerJdbc <?> source ) {
43
+ super (source );
44
+ this .executionStartTimeMillis = source .executionStartTimeMillis ;
43
45
}
44
46
45
47
@ Override
@@ -83,7 +85,7 @@ protected Stream<GridOSHEntity> getOshCellsStream(CellIdRange cellIdRange) {
83
85
pstmt .setLong (3 , cellIdRange .getEnd ().getId ());
84
86
var oshCellsRawData = pstmt .executeQuery ();
85
87
return StreamSupport .stream (spliteratorUnknownSize (
86
- new GridOSHEntityIterator (oshCellsRawData , conn ), 0
88
+ new GridOSHEntityIterator (oshCellsRawData , pstmt , conn ), 0
87
89
), false );
88
90
} catch (SQLException e ) {
89
91
throw new OSHDBException (e );
@@ -93,11 +95,13 @@ protected Stream<GridOSHEntity> getOshCellsStream(CellIdRange cellIdRange) {
93
95
private class GridOSHEntityIterator implements Iterator <GridOSHEntity > {
94
96
95
97
private final ResultSet oshCellsRawData ;
98
+ private final PreparedStatement preparedStatement ;
96
99
private final Connection conn ;
97
100
GridOSHEntity next ;
98
101
99
- public GridOSHEntityIterator (ResultSet oshCellsRawData , Connection conn ) {
102
+ public GridOSHEntityIterator (ResultSet oshCellsRawData , PreparedStatement pstmt , Connection conn ) {
100
103
this .oshCellsRawData = oshCellsRawData ;
104
+ this .preparedStatement = pstmt ;
101
105
this .conn = conn ;
102
106
}
103
107
@@ -121,6 +125,7 @@ private GridOSHEntity getNext() {
121
125
if (!oshCellsRawData .next ()) {
122
126
try {
123
127
oshCellsRawData .close ();
128
+ preparedStatement .close ();
124
129
} finally {
125
130
conn .close ();
126
131
}
0 commit comments