[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] Connnection to postgis
|
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.