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);
}
}
}
}
}