use of org.sqlite.core.CoreConnection in project com.revolsys.open by revolsys.
the class GeoPackageRecordStore method initializeDo.
@Override
@PostConstruct
public void initializeDo() {
super.initializeDo();
setUsesSchema(false);
final String filter = "WHERE NOT (NAME LIKE 'GPKG%' OR NAME LIKE 'RTREE%' OR NAME LIKE 'SQLITE%')";
setSchemaTablePermissionsSql("select '/' \"SCHEMA_NAME\", name \"TABLE_NAME\", 'ALL' \"PRIVILEGE\", '' \"REMARKS\" from sqlite_master " + filter + " union all " + "select '/' \"SCHEMA_NAME\", name \"TABLE_NAME\", 'ALL' \"PRIVILEGE\", '' \"REMARKS\" from sqlite_temp_master " + filter);
addFieldAdder("BOOLEAN", DataTypes.BOOLEAN);
addFieldAdder("TINYINT", DataTypes.BYTE);
addFieldAdder("SMALLINT", DataTypes.SHORT);
addFieldAdder("MEDIUMINT", DataTypes.INT);
addFieldAdder("INT", DataTypes.LONG);
addFieldAdder("BIG_INTEGER", DataTypes.LONG);
addFieldAdder("FLOAT", DataTypes.FLOAT);
addFieldAdder("DOUBLE", DataTypes.DOUBLE);
addFieldAdder("REAL", DataTypes.DOUBLE);
addFieldAdder("TEXT", DataTypes.STRING);
addFieldAdder("BLOB", DataTypes.BLOB);
addFieldAdder("DATE", DataTypes.SQL_DATE);
addFieldAdder("DATETIME", DataTypes.DATE_TIME);
final GeoPackageGeometryFieldAdder geometryAdder = new GeoPackageGeometryFieldAdder();
addFieldAdder("GEOMETRY", geometryAdder);
addFieldAdder("POINT", geometryAdder);
addFieldAdder("LINESTRING", geometryAdder);
addFieldAdder("POLYGON", geometryAdder);
addFieldAdder("GEOMETRYCOLLECTION", geometryAdder);
addFieldAdder("MULTIPOINT", geometryAdder);
addFieldAdder("MULTILINESTRING", geometryAdder);
addFieldAdder("MULTIPOLYGON", geometryAdder);
super.initialize();
try (JdbcConnection connection = getJdbcConnection(true)) {
final CoreConnection sqliteConnection = (CoreConnection) ((DelegatingConnection<?>) connection.getConnection()).getInnermostDelegate();
final DB db = sqliteConnection.db();
db.enable_load_extension(true);
try {
db._exec("select load_extension('libgpkg')");
} finally {
db.enable_load_extension(false);
}
} catch (final SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations