Hi all,

I've just started working with GeoTools, so please be gentle... but I can't
seem to determine how to resolve the "WARNING: There is code leaving feature
readers/iterators open, this is leaking statements and connections!"
problem.

As per other posts, I've added -Dgt2.jdbc.trace=true to my run configuration
(trace is below) but I'm not sure how to resolve the error/warning when I'm
not explicitly invoking an iterator.

My Maven pom is referring to -9-SNAPSHOT, SQL Server 2008 R2 x64 and I'm
using sqljdbc4.jar from the Eclipse-Juno IDE. I'm working with the following
code to add features to the map but each layer is giving me the above
warning. Here is the code:


class DisplayPlotsAction extends SafeAction
        {

                public DisplayPlotsAction()
                {
                        super("DisplayPlotsAction");
                        putValue(Action.SHORT_DESCRIPTION, "Displays the 
recorded plots in the
database.");
                }

                @Override
                public void action(ActionEvent e) throws Throwable
                {
                        //Create the coverage buffer zone around the selected 
site, if TYPE = 1
(RAMP)
                        
                        //(Site Id = 25)  or RECORDING_ID = 19 or RECORDING_ID 
= 20
                        Query query = new Query("TARGET_MESSAGES_3161", 
CQL.toFilter("SOURCE_ID =
25"), new String[] {"ID", "CoordGeocodePoint_SPA"});
                        
                        DateFormat dateFormat = new 
SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                        Date date = new Date();
                        
                        System.out.println("START: " + dateFormat.format(date));
                        SimpleFeatureSource sfs = 
ds.getFeatureSource("TARGET_MESSAGES_3161");
                        SimpleFeatureCollection features_25 = 
sfs.getFeatures(query);   
                                                
                        Style style = SLD.createPointStyle("Circle", 
Color.GREEN, Color.GREEN,
1.0f, 4f);
                        Layer layer_25 = new FeatureLayer(features_25, style);
                        map.addLayer(layer_25);

                        
                        date = new Date();
                        System.out.println("END: " + dateFormat.format(date));
                        
                        // (Site Id = 22)
                        Query query_22 = new Query("TARGET_MESSAGES_3161",
CQL.toFilter("SOURCE_ID = 23"), new String[] {"ID",
"CoordGeocodePoint_SPA"});
                        SimpleFeatureCollection features_22 = 
sfs.getFeatures(query_22);        
                                                
                        Style style_22 = SLD.createPointStyle("Circle", 
Color.BLUE, Color.BLUE,
1.0f, 4f);
                        Layer layer_22 = new FeatureLayer(features_22, 
style_22);
                        layer_22.setSelected(false);
                        map.addLayer(layer_22);
                        
                        // (Site Id = 29)
                        Query query_29 = new Query("TARGET_MESSAGES_3161",
CQL.toFilter("SOURCE_ID = 30"), new String[] {"ID",
"CoordGeocodePoint_SPA"});
                        SimpleFeatureCollection features_29 = 
sfs.getFeatures(query_29);        
                                                
                        Style style_29 = SLD.createPointStyle("Circle", 
Color.RED, Color.RED,
1.0f, 4f);
                        Layer layer_29 = new FeatureLayer(features_29, 
style_29);
                        layer_29.setSelected(false);
                        map.addLayer(layer_29);

                }

                
                
        }// end DisplayPlotsAction class








Oct 29, 2012 2:02:28 PM org.geotools.jdbc.JDBCFeatureReader finalize
WARNING: There is code leaving feature readers/iterators open, this is
leaking statements and connections!
Oct 29, 2012 2:02:28 PM org.geotools.jdbc.JDBCFeatureReader finalize
WARNING: The unclosed reader originated on this stack trace
java.lang.Exception
        at org.geotools.jdbc.JDBCFeatureReader.init(JDBCFeatureReader.java:169)
        at 
org.geotools.jdbc.JDBCFeatureReader.<init>(JDBCFeatureReader.java:132)
        at
org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:580)
        at
org.geotools.jdbc.JDBCFeatureStore.getReaderInternal(JDBCFeatureStore.java:225)
        at
org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:562)
        at
org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:238)
        at
org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:68)
        at
org.geotools.data.collection.CollectionDataStore.getBoundsInternal(CollectionDataStore.java:152)
        at
org.geotools.data.collection.CollectionDataStore.getBounds(CollectionDataStore.java:145)
        at
org.geotools.data.AbstractFeatureSource.getBounds(AbstractFeatureSource.java:318)
        at
org.geotools.data.AbstractFeatureSource.getBounds(AbstractFeatureSource.java:286)
        at org.geotools.map.FeatureLayer.getBounds(FeatureLayer.java:195)
        at org.geotools.map.MapContent.getMaxBounds(MapContent.java:600)
        at
org.geotools.swing.AbstractMapPane.setFullExtent(AbstractMapPane.java:939)
        at 
org.geotools.swing.AbstractMapPane.layerAdded(AbstractMapPane.java:794)
        at org.geotools.map.MapContent.fireLayerAdded(MapContent.java:467)
        at 
org.geotools.map.MapContent$LayerList.addIfAbsent(MapContent.java:1062)
        at org.geotools.map.MapContent.addLayer(MapContent.java:368)
        at
ca.navcanada.sift_map.sift_map$DisplayPlotsAction.action(sift_map.java:338)
        at 
org.geotools.swing.action.SafeAction.actionPerformed(SafeAction.java:50)
        at 
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
        at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
        at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at 
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at 
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
        at java.awt.Component.processMouseEvent(Component.java:6505)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
        at java.awt.Component.processEvent(Component.java:6270)
        at java.awt.Container.processEvent(Container.java:2229)
        at java.awt.Component.dispatchEventImpl(Component.java:4861)
        at java.awt.Container.dispatchEventImpl(Container.java:2287)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at 
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
        at java.awt.Container.dispatchEventImpl(Container.java:2273)
        at java.awt.Window.dispatchEventImpl(Window.java:2719)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:682)
        at java.awt.EventQueue$3.run(EventQueue.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.awt.EventQueue$4.run(EventQueue.java:696)
        at java.awt.EventQueue$4.run(EventQueue.java:694)
        at java.security.AccessController.doPrivileged(Native Method)
        at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
        at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
        at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

        

Thanks in advance!


Adam Stewart



--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/SQL-2008R2-readers-iterators-being-left-open-tp5012067.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Windows 8 Center - In partnership with Sourceforge
Your idea - your app - 30 days.
Get started!
http://windows8center.sourceforge.net/
what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to