Hello list,
I have no problem using directly a FeatureSource (comments) but
with FeatureCollection. See erro at the end.....
Thanks a lot for any ideia !


here my code:

        PostgisNGDataStoreFactory pgis = new PostgisNGDataStoreFactory();
        java.util.Map params = new java.util.HashMap();
        params.put(PostgisNGDataStoreFactory.DBTYPE.key, "postgis");
        params.put(PostgisNGDataStoreFactory.HOST.key, "localhost");
        params.put(PostgisNGDataStoreFactory.PORT.key, "5432");
      //[...]

        try {
            dataStore = pgis.createDataStore(params);
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }

        MapContent map = new MapContent();

        Filter filter = null;
        try {
            filter = CQL.toFilter("status LIKE 'ON'");
        } catch (CQLException ex) {
            System.out.println(ex.getMessage());
        }

        Query myQuery = new Query("stands", filter);

 // Using featureSource, run perfectly !
        //FeatureSource fsStands = dataStore.getFeatureSource("stands");
        //Layer layer_stands = new FeatureLayer(fsStands, myStyle,
"stands");

  // Using SimpleFeatureCollection give error
        SimpleFeatureCollection sfc_stands =
dataStore.getFeatureSource("stands").getFeatures(myQuery);
        Layer layer_stands = new FeatureLayer(sfc_stands, myStyle,
"stands");
        System.out.println("Features nº = " + sfc_stands.size()); // ok...
        map.addLayer(layer_stands);
        JMapFrame.showMap(map);



Error:
run:
Features nº = 1076
25/Fev/2012 12:11:28 org.geotools.jdbc.JDBCFeatureReader finalize
WARNING: There is code leaving feature readers/iterators open, this is
leaking statements and connections!
25/Fev/2012 12:11:28 org.geotools.jdbc.JDBCFeatureReader finalize
WARNING: There is code leaving feature readers/iterators open, this is
leaking statements and connections!
25/Fev/2012 12:11:28 org.geotools.jdbc.JDBCDataStore closeSafe
WARNING: Error occurred closing connection
25/Fev/2012 12:11:28 org.geotools.renderer.lite.StreamingRenderer
fireErrorEvent
SEVERE: java.io.IOException
java.lang.RuntimeException: java.io.IOException
        at
org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:224)
        at
org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:64)
        at
org.geotools.data.collection.CollectionDataStore.getFeatureReader(CollectionDataStore.java:123)
        at
org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:403)
        at
org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:369)
        at
org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:214)
        at
org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:230)
        at
org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:198)
        at
org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2297)
        at
org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1982)
        at
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:804)
        at org.geotools.swing.RenderingTask.call(RenderingTask.java:106)
        at org.geotools.swing.RenderingTask.call(RenderingTask.java:41)
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.IOException
        at
org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:610)
        at
org.geotools.jdbc.JDBCFeatureStore.getReaderInternal(JDBCFeatureStore.java:220)
        at
org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:562)
        at
org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:221)
        ... 17 more
Caused by: org.postgresql.util.PSQLException: An I/O error occured while
sending to the backend.
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:252)
        at
org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
        at
org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
        at
org.geotools.jdbc.JDBCFeatureReader.<init>(JDBCFeatureReader.java:140)
        at
org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:580)
        ... 20 more
Caused by: java.net.SocketException: Socket closed
        at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at org.postgresql.core.PGStream.flush(PGStream.java:508)
        at
org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:1107)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:256)
        ... 27 more
25/Fev/2012 12:11:31 org.geotools.jdbc.JDBCFeatureReader finalize
WARNING: There is code leaving feature readers/iterators open, this is
leaking statements and connections!
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to