Hello,
I am developing an application using Geotools. The framework used for the
application is Quarkus. The application connects to the PostGIS database.
Since it is a web application I want to minimize the overheads in
connecting to the database in each request. I want to reuse an already
connected database.
I have maintained an application level DataStore object which gets created
when the application starts up.
Map<String, Object> params = new HashMap<>();
params.put("dbtype", "postgis");
params.put("host", this.dbConfig.getHost());
params.put("port", this.dbConfig.getPort());
params.put("schema", "public");
params.put("database" ,this.dbConfig.getDatabase());
params.put("user", this.dbConfig.getUser());
params.put("passwd", this.dbConfig.getPassword());
params.put("preparedStatements", true);
params.put("encode functions", true);
try {
this.dataStore = (JDBCDataStore) DataStoreFinder.getDataStore(params);
} catch (IOException e) {
Logger.getLogger(DataSourceService.class.getName()).warning(e.getMessage());
} catch (SQLException e) {
Logger.getLogger(DataSourceService.class.getName()).warning(e.getMessage());
}
---------
Then I am using the dataStore object in the rest of the places.
Is this the proper way of doing or should I use DataStoreFinder each time
to find the datastore and dispose of the data store at the end of
processing request?
Can I plug connection pools like HikariCP to get datastore out of that
connection?
When I leave the application idle for a long time I am getting this error.
java.sql.SQLException: An I/O error occurred while sending to the backend.
Please suggest the best way of doing it.
Thanks in advance.
Sunish.
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users