0

I wrote the following method as an onClick handler. First and second click, I got result from DB. By the third time, the code stopped in the "getFeatures(trgtFilter)" line and didn't return. In debug mode, I saw that it is waiting for DB connection. Can someone tell me what I did wrong? I'm using GeoTools 15 and Oracle 12.

private Geometry getNewGeometry(String refID) throws Exception {
    if (trgLayer != null) {
        Connection con = null;
        OracleConnection oraCon=null;
        FeatureIterator<SimpleFeature> itr = null;
        try {
            con = ((JDBCDataStore) srcLayer.getFeatureSource().getDataStore()).getConnection(Transaction.AUTO_COMMIT);              
            oraCon = (OracleConnection) new DelegatingConnection(con).getInnermostDelegate();

            Filter trgtFilter = editTask.getConfiguration().getReferenceFilter(trgLayer, refID);
            FeatureCollection fc = trgLayer.getFeatureSource().getFeatures(trgtFilter);
            itr = fc.features();
            if (!itr.hasNext())
                return null;
            ...
        } catch (Exception e) {
            throw e;
        } finally {
            if (itr != null)
                itr.close();
            if (oraCon != null) {
                try {
                    oraCon.close();
                    if (con != null && !con.isClosed())
                        con.close();
                } catch (SQLException e) {
                    LOGGER.error("", e);
                }
            }
        }
    }
}
springrolls
  • 1,331
  • 1
  • 14
  • 40

1 Answers1

0

If the filter is an 'id' filter, it could be that there is no index on that column in the Oracle table. If that's the case, the database will do a full-table scan.

Assuming you have a geospatial index and assuming the user is 'zoomed-in' on a given area, you could add the user viewport's geo-bounds to the query. With that query, the database can use the geo-index.

Alternatively, you can create an index on the fid/id column for the table if look-ups by feature id are going to be common.

GeoJim
  • 1,320
  • 7
  • 12