Hello
For initiating the graphhopper, In past i import the shape file or osm file by this method:
setDataReaderFile(ShapeFile)
Now i want to import the table from the PostgreSQL as my Source File
I write a reader for PostgreSQL and open the database connection in this reader and pass my goal table as “FeatureSource”.
I write the below code for connection to database but datastore object is null
AbstractDataStoreFactory dataStoreFactory = new PostgisNGDataStoreFactory();
Map<String, Serializable> params = Maps.newHashMap();
params.put(PostgisNGDataStoreFactory.DBTYPE.key, “postgis”);
params.put(PostgisNGDataStoreFactory.HOST.key, “192.168.196.67”);
params.put(PostgisNGDataStoreFactory.PORT.key, “5432”);
params.put(PostgisNGDataStoreFactory.SCHEMA.key, “public”);
params.put(PostgisNGDataStoreFactory.DATABASE.key, “t1”);
params.put(PostgisNGDataStoreFactory.USER.key, “postgres”);
params.put(PostgisNGDataStoreFactory.PASSWD.key, “****”);
params.put(PostgisNGDataStoreFactory.FETCHSIZE.key, 1000);
params.put(PostgisNGDataStoreFactory.EXPOSE_PK.key, true);
DataStore dataStore;
try {
dataStore= dataStoreFactory.createDataStore(params); } catch (IOException e) {
throw new CommandFailedException(
“Unable to connect using the specified database parameters.”, e);
}
if (dataStore == null) {
throw new CommandFailedException(
“Unable to connect using the specified database parameters.”);
Best Regards