1

Working my way through GeoTools. Just trying to read features from a view in postgresql that is not in public schema. I have a bunch of views in a schema called cache

store = DataStoreFinder.getDataStore(map);
// print a bunch of tables and views including the one I want
for(String s:store.getTypeNames()) 
   System.out.println(s);

I can see my view name in the list eg: vw_well without the prefix cache

but

featureSource = store.getFeatureSource("vw_well");

will generate

WARNING: Error occured determing srid for vw_well.geom
org.postgresql.util.PSQLException: ERROR: relation "public.vw_well" does not exist

and

featureSource = store.getFeatureSource("cache.vw_well");

generates

Schema 'cache.vw_well' does not exist.

Any way to tell GeoTools to read in a different schema than `public. I googled around I could not find an answer.

Thank you.

Eric Boisvert
  • 135
  • 3
  • 9

1 Answers1

1

You don't show the code setting your map of parameters, but I suspect you didn't include a schema key so the database connection defaults to public. You need a line like:

map.put(PostgisNGDataStoreFactory.SCHEMA.key, "cache");
Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • Thanks. I did not expect it would be in the connection parameters since it implies one is limited to a single schema per connection. But in my particular case, it solves the problem. Thanks – Eric Boisvert Mar 01 '22 at 13:06
  • You are limited to one schema per connection - allows for some security and separation of concerns – Ian Turton Mar 01 '22 at 13:23