Hi,

 

finally I found the problem, it was the following line that is not allowed:

 

      SimpleFeature adresse = fc.iterator().next();  

 

As FeatureCollaction provides the method
<http://java.sun.com/j2se/1.5/docs/api/java/util/Iterator.html> Iterator<
<http://docs.geotools.org/stable/javadocs/org/geotools/feature/FeatureCollec
tion.html> F> iterator() I assumed it behaves like java.lang.Iterable,  but
it does NOT !
 
Of course I have to acknowledge that this issue is well documented in the
JavaDoc of FeatureCollection, but I still think the name of the iterator()
method should be reconsidered, as it makes this misunderstanding more
likely.
 
For the sake of completeness here the correct replacement of the wrong line:
 

Iterator<SimpleFeature> sfit = fc.iterator();

SimpleFeature adresse = sfit.next();

fc.close(sfit);

 

 

Stefan

  _____  

Von: Schuster Stefan [mailto:[email protected]] 
Gesendet: Freitag, 19. November 2010 11:27
An: [email protected]
Betreff: [Geotools-gt2-users] ArcSDEDataStore Session pool exhausted

 

Hi,

 

I'm using geotools to connect to an ArcSDE Database. I reuse a single
instance of the Datastore created by the corresponding factory:

 

ArcSDEDataStoreFactory factory = new ArcSDEDataStoreFactory();

DataStore store = factory.createDataStore(params);

 

Later I use this store to read data like in this debug method:

 

private void debug(DataStore store) throws IOException, CQLException {

      String strassenkennziffer = "3162";

      String hausnummer = "150";

      

      FeatureSource<SimpleFeatureType, SimpleFeature> s = store

                  .getFeatureSource("GIS.ADDRESS");

      Filter filter = CQL.toFilter("STRASSENKENNZIFFER == '"

                  + strassenkennziffer + "' AND HAUSNUMMER == '" +
hausnummer

                  + "'");

      FeatureCollection<SimpleFeatureType, SimpleFeature> fc = s

                  .getFeatures(filter);

 

      if (fc.size() != 1) {

            log("Not exactly one address found");

            return;

      }

      SimpleFeature adresse = fc.iterator().next();  

      Object oAref = adresse.getDefaultGeometry();

      if (!(oAref instanceof Point)) {

            log("adrdess is not a point");

            return;

      }

      Point adressPoint = (Point) oAref;

      log("Coordinates of adress: X:" + adressPoint.getX() + " Y:"

                  + adressPoint.getY());  

}

 

 

This works fine, but only for 6 successive calls of the debug method, in the
7th call I receive the following exception:

 

19.11.2010 11:22:05 org.geotools.arcsde.session.SessionPool getSession

WARNUNG: Out of connections: Timeout waiting for idle object. Config:
ArcSDEConnectionConfig[server=nyx, port=5151, database=null, user=sde,
minConnections=2, maxConnections=6, timeout=500]

java.lang.RuntimeException: Session pool exhausted

      at
org.geotools.arcsde.data.ArcSDEDataStore.getSession(ArcSDEDataStore.java:179
)

      at
org.geotools.arcsde.data.ArcSdeFeatureSource.getSession(ArcSdeFeatureSource.
java:248)

      at
org.geotools.arcsde.data.ArcSdeFeatureSource.getCount(ArcSdeFeatureSource.ja
va:215)

      at
org.geotools.arcsde.data.ArcSdeFeatureCollection.getCount(ArcSdeFeatureColle
ction.java:104)

      at
org.geotools.data.store.DataFeatureCollection.size(DataFeatureCollection.jav
a:265)

      at
de.gevas.geotools.konverter.feuerwehr.TestGui.debug(TestGui.java:302)  

 

 

Do I have to release something?

 

Tanks for help!

 

Stefan

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to