On Sat, Dec 31, 2011 at 12:15 AM, Alessandro Ferrucci <
[email protected]> wrote:

> public class Main2
> {
>
>     public static void main(String[] args)
>     {
>         Map params = new HashMap();
>         params.put("dbtype", "postgis");             //must be postgis
>         params.put("host", "myhost");        //the name or ip address of
> the machine running PostGIS
>         params.put("port", new Integer(5432));        //the port that
> PostGIS is running on (generally 5432)
>         params.put("database", "spatial");        //the name of the
> database to connect to.
>         params.put("user", "dbuser");                 //the user to
> connect with
>         params.put("passwd", "dbuser");               //the password of
> the user.
>         params.put("max connections", 1);
>         DataStore datastore = null;
>         try
>         {
>             datastore = DataStoreFinder.getDataStore(params);
>             FeatureReader<SimpleFeatureType, SimpleFeature> featureReader
> = null;
>             String[] columns = new String[]
>             {
>                 "the_geom", "colblkst",
>                 "colblkcou", "colblk"
>             };
>             for (int x = 0; x < 10; x++)
>             {
>                 try
>                 {
>                     System.out.println("going once!");
>
>                     String filterstr = "colblkst='01' and colblkcou='001'
> and colblk='10163'";
>                     Filter filter = CQL.toFilter(filterstr);
>                     Transaction transaction = new DefaultTransaction();
>                     DefaultQuery q = new DefaultQuery("collection_blocks",
> filter, columns);
>                     featureReader = datastore.getFeatureReader(q,
> transaction /*null*/);
>                     if (featureReader.hasNext())
>                     {
>                         SimpleFeature f = featureReader.next();
>                     }
>                     transaction.commit();
>                     featureReader.close();
>                  //   Thread.sleep(100000);
>                 }
>                 catch (Exception ex)
>                 {
>                     ex.printStackTrace();
>                 }
>             }
>         }
>         catch (IOException ex)
>         {
>             ex.printStackTrace();
>             System.exit(-1);
>         }
>     }
> }


The connection is bound to the transaction, but you're not calling
Transaction.close()
to release it

Cheers
Andrea

-- 
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:      +39 0584 962313
mob:    +39 339 8844549

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

Please take note that GeoSolutions will be closed for Christmas holidays
from 27/12 to 30/12

-------------------------------------------------------
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to