Hi,

What version of uDig are you using? 


On Dec 16, 2009, at 5:47 PM, Elton Chan wrote:

> 
> Hi there,
> 
> I try the following:
>        Map<String, Serializable> params = new HashMap<String,
> Serializable>();
>        params.put("dbtype", "postgis");        //must be postgis
>        params.put("host", "localhost");        //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", "postgis");      //the name of the database
> to connect to.
>        params.put("user", "postgres");         //the user to connect with
>        params.put("passwd", "");               //the password of the user.
> 
> IServiceFactory serviceFactory =
> CatalogPlugin.getDefault().getServiceFactory();
> for( IService service : serviceFactory.createService( params ) ){
>     try {
>         IServiceInfo info = service.getInfo( null );  // try connecting to
> make sure the service works
>         CatalogPlugin.getDefault().getLocalCatalog().add( service );
>     }
>     catch (IOException couldNotConnect ){
>     }
> }
> However, it appears the above code cannot create service with the params.
> Instead, I use the following it is working fine.
> 
>            DataStore dataStore=DataStoreFinder.getDataStore(params);
>          for (Name na:dataStore.getNames()){
>              System.out.println(na);}
> 
> I wonder why the first code is not working and what is the standard way to
> connect postgis in udig? I know the second is using GeoTools. In addition, I
> also try service:canResolve(PostgisDataStore.class), but eclipse never
> resolve the "PostgisDataStore.class" and also the PostgisDataStore type in
> udig. Anybody can hint me the reason and if possible any sample code to
> connect to postgis and access particular feature class in udig?
> 
> Thanks.
> -- 
> View this message in context: 
> http://old.nabble.com/Connnection-to-postgis-tp26814178p26814178.html
> Sent from the udig-devel mailing list archive at Nabble.com.
> 
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to