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