Hello Florian
The following line:
Configuration.current().setDatabase((Supplier<DataSource>)
createDataSource());
Should be replaced by:
Configuration.current().setDatabase(MyJavaApp::createDataSource);
Where MyJavaApp is the class where is defined the createDataSource()
static method. Everything else should be fine.
With this setting, MyJavaApp.createDataSource() will be invoked by SIS
exactly once the first time that an EPSG code is used. Then the
DataSource.getConnection() method will invoked (by SIS again) for
getting the connection. The connection will be used and closed after a
short timeout. There is no need to open and close connections on your side.
The first time that a connection is established, SIS will search for
EPSG tables in all database schemas and will remember in which schema
the tables were found. So it is okay to put the EPSG tables in any
schema (not necessarily "public"). On my side I like to create a
separated "epsg" schema for those tables.
If there is many copies of EPSG dataset in different schemas, SIS checks
the EPSG dataset version number and use by default the most recent EPSG
dataset. It is possible to request to use of a specific version of EPSG
dataset by specifying the version number before EPSG code, for example
"EPSG:9.0:4326".
One last note: the SQL scripts provided by EPSG do not include the
creation of index. For better performances, you may want to also execute
the following file in SIS repository:
core/sis-referencing/src/main/resources/org/apache/sis/referencing/factory/sql/EPSG_Finish.sql
Martin