Commit 311c4372 authored by Luna Riegel's avatar Luna Riegel
Browse files

Feat: Create spatial index in embedded database

parent 3cd96976
...@@ -38,8 +38,8 @@ public record EmbeddedDatabaseConfiguration(String databaseName, String database ...@@ -38,8 +38,8 @@ public record EmbeddedDatabaseConfiguration(String databaseName, String database
true, true, true, false); true, true, true, false);
} }
public String wrapUrlWithH2JdbcDriver(String Url){ public String wrapUrlWithH2JdbcDriver(String url){
return JDBC_DRIVER_PREFIX + Url + getH2ParametersSuffix(); return JDBC_DRIVER_PREFIX + url + getH2ParametersSuffix();
} }
public String getInMemoryH2Url() { public String getInMemoryH2Url() {
......
...@@ -121,17 +121,20 @@ public class EmbeddedDatabaseHandler { ...@@ -121,17 +121,20 @@ public class EmbeddedDatabaseHandler {
try (Connection con = dataSource.getConnection()) { try (Connection con = dataSource.getConnection()) {
try (PreparedStatement dropPs = con.prepareStatement("DROP TABLE IF EXISTS features")){ try (PreparedStatement dropPs = con.prepareStatement("DROP TABLE IF EXISTS features")){
dropPs.executeUpdate(); dropPs.executeUpdate();
if (logger.isDebugEnabled()) { logger.trace("Dropped existing features table");
logger.debug("Dropped existing features table");
} }
try (PreparedStatement dropIndexPs = con.prepareStatement("DROP INDEX IF EXISTS FEATURES_SPATIAL_INDEX")){
dropIndexPs.executeUpdate();
logger.trace("Dropped existing spatial index");
} }
try (PreparedStatement createPs = con.prepareStatement("CREATE TABLE features (gmlid VARCHAR(255)" + try (PreparedStatement createPs = con.prepareStatement("CREATE TABLE features (gmlid VARCHAR(255)" +
" PRIMARY KEY, bbox GEOMETRY, data BLOB, errors BOOLEAN);")) { " PRIMARY KEY, bbox GEOMETRY, data BLOB, errors BOOLEAN);")) {
createPs.executeUpdate(); createPs.executeUpdate();
if (logger.isDebugEnabled()) { logger.trace("Created features table");
logger.debug("Created features table");
} }
//CREATE SPATIAL INDEX GEO_TABLE_SPATIAL_INDEX ON GEO_TABLE(THE_GEOM); <- Create spatial id try (PreparedStatement createIndexPs = con.prepareStatement("CREATE SPATIAL INDEX FEATURES_SPATIAL_INDEX ON features(bbox);")){
createIndexPs.executeUpdate();
logger.trace("Created spatial index");
} }
} catch (SQLException e) { } catch (SQLException e) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment