Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Connnection to postgis

Do you have a dependency on net.refractions.udig.libs?  Because that plugin should have the postgis class.  Without that dependency you certainly cannot look it up.  Also do you need to use the DataStoreFinder?  Can you just instantiate PostgisDataStoreFactory?

Jesse

On Dec 17, 2009, at 11:49 AM, Elton Chan wrote:

> 
> Hi,
> 
> I am using version 1.2 from trunk with Eclipse 3.5.1. Do you mean postgis
> can only supported by lower version?
> 
> Thanks,
> Elton
> 
> 
> 
> 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-tp26814178p26826213.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



Back to the top