use of org.geotools.data.postgis.PostgisNGDataStoreFactory in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createPostgres.
/**
* Creates a new DatabaseConnection object for Postgres.
*
* @return the database connection
*/
public static DatabaseConnection createPostgres() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.PORT));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.SCHEMA));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.USER));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.PASSWD));
PostgisNGDataStoreFactory factory = new PostgisNGDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(PostgisNGDataStoreFactory.DBTYPE, factory.getDisplayName(), true, list, new DatabaseConnectionName() {
@Override
public String getConnectionName(String duplicatePrefix, int noOfTimesDuplicated, Map<String, String> properties) {
String connectionName = String.format("%s/%s@%s:%s", properties.get(PostgisNGDataStoreFactory.SCHEMA.key), properties.get(PostgisNGDataStoreFactory.DATABASE.key), properties.get(PostgisNGDataStoreFactory.HOST.key), properties.get(PostgisNGDataStoreFactory.PORT.key));
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
Aggregations