2
2
3
3
import static org .heigit .ohsome .oshdb .helpers .db .Util .getInterpolated ;
4
4
5
- import java . sql . DriverManager ;
5
+ import com . zaxxer . hikari . HikariDataSource ;
6
6
import java .util .Properties ;
7
7
import org .apache .ignite .Ignite ;
8
8
import org .apache .ignite .Ignition ;
9
9
import org .heigit .ohsome .oshdb .api .db .OSHDBH2 ;
10
10
import org .heigit .ohsome .oshdb .api .db .OSHDBIgnite ;
11
- import org .heigit .ohsome .oshdb .api .db .OSHDBJdbc ;
12
11
13
12
/**
14
13
* A basic OSHDBDriver class for connecting to h2 or ignite oshdb instances.
@@ -87,14 +86,13 @@ private static int connectToH2(Properties props, Execute connect)
87
86
@ SuppressWarnings ("java:S112" )
88
87
private static int connectToH2 (String h2 , String prefix , boolean multithreading ,
89
88
Execute connect ) throws Exception {
90
- try (final var oshdb = new OSHDBH2 (h2 );
91
- final var keyTables = new OSHDBJdbc (oshdb .getConnection ())) {
89
+ try (final var oshdb = new OSHDBH2 (h2 )) {
92
90
oshdb .prefix (prefix );
93
91
oshdb .multithreading (multithreading );
94
92
var props = new Properties ();
95
93
props .setProperty (OSHDBDriver .OSHDB_PROPERTY_NAME , h2 );
96
94
props .setProperty (PREFIX_PROPERTY_NAME , prefix );
97
- final var connection = new OSHDBConnection (props , oshdb , keyTables );
95
+ final var connection = new OSHDBConnection (props , oshdb );
98
96
return connect .apply (connection );
99
97
}
100
98
}
@@ -107,17 +105,19 @@ private static int connectToIgnite(Properties props, Execute connect)
107
105
.filter (value -> value .toLowerCase ().startsWith (IGNITE_URI_PREFIX ))
108
106
.map (value -> value .substring (IGNITE_URI_PREFIX .length ()))
109
107
.orElseThrow ();
108
+ // start ignite
110
109
try (var ignite = Ignition .start (cfg )) {
111
110
var prefix = getInterpolated (props , PREFIX_PROPERTY_NAME ).orElseGet (() -> getActive (ignite ));
112
111
props .put (PREFIX_PROPERTY_NAME , prefix );
113
112
var keyTablesUrl = getInterpolated (props , OSHDBDriver .KEYTABLES_PROPERTY_NAME )
114
113
.orElseThrow (() -> new IllegalArgumentException ("missing keytables" ));
115
114
props .put (OSHDBDriver .KEYTABLES_PROPERTY_NAME , keyTablesUrl );
116
- try (var ktConnection = DriverManager .getConnection (keyTablesUrl );
117
- var keytables = new OSHDBJdbc (ktConnection );
118
- var oshdb = new OSHDBIgnite (ignite )) {
115
+ // initialize data source for keytables
116
+ try (var dsKeytables = new HikariDataSource ();
117
+ var oshdb = new OSHDBIgnite (ignite , dsKeytables )) {
118
+ dsKeytables .setJdbcUrl (keyTablesUrl );
119
119
oshdb .prefix (prefix );
120
- var connection = new OSHDBConnection (props , oshdb , keytables );
120
+ var connection = new OSHDBConnection (props , oshdb );
121
121
return connect .apply (connection );
122
122
}
123
123
}
0 commit comments