Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Problem setting up a database connection

I just can't tell why PostgisService2 can't resolve to any of the objects it was supposed to ( Connection or PostgisDataStore).
I noticed that when service.canResolve(A.class) method is called, ResolveManager.canResolve(A.class) will also be called. And this method should return true. But this is not the case.
Inside the method there are two for-loops. The first for-loop cycles thru ResolveManager.factories.entrySet(),which contains [org.eclipse.core.internal.registry.ConfigurationElementHandle@6a1=null, org.eclipse.core.internal.registry.ConfigurationElementHandle@422=null].

The second for-loop cycles thru the registeredFactories HashSet which is empty.

Has anybody recently try to connect to a Postgis Db using the code from the wiki ? Can anybody give a hint to what may cause this problem?


From: George Schole <georgeschole@xxxxxxxxx>
To: "udig-devel@xxxxxxxxxxxxxxxxxxxxx" <udig-devel@xxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, June 1, 2012 4:47 PM
Subject: [udig-devel] Problem setting up a database connection





Hi all,
I tried to programatically connect to a postgis database, using the example from here: http://udig.refractions.net/confluence/display/DEV/2+Catalog#2Catalog-IService , but local.acquire(params,new NullProgressMonitor) returns null. With the same parameters I did successfuly connect to a postgis database through the udig application,thus ruling out the possibility that the params are wrong.
The problem seems to be that PostgisNGDataStoreFactory.checkDBType(Map params) returns false (see line 99 in the class file).

L.E. :If I use postgisng as dbtype ( the wiki says that dbtype “must be postgis”) then acquire() returns PostgisService2 ( which is good, right?). But now comes another problem: to issue jdbc commands I need to adapt PostgisService2 to Connection.class.But PostgisService2.canResolve(Connection.class) and also PostgisService2.canResolve( PostgisDataStore.class ) returns false.Anybody know what the problem is?

BTW: The udig application uses another way (which obviously should be described in the wiki in place of the other, apparently useless, method). It creates a DatabaseConnectionRunnable in which it bypasses the service acquire/ construction part and the canResolve checks and essentially does
BasicDataSource source = PostgisServiceExtension2.getFactory().createDataSource(params );
Connection connection = source.getConnection();
Looks like the udig application doesn't always respect the guidelines set by the devs :) So,in the end, how should I connect to a database ( a postgis one to be precise)?

Thank you in advance for your response



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



Back to the top