use of org.geotools.data.db2.DB2NGDataStoreFactory in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createDB2.
/**
* Creates a new DatabaseConnection object for DB2.
*
* @return the database connection
*/
public static DatabaseConnection createDB2() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.PORT));
Param TABSCHEMA = new Param("tabschema", String.class, "Schema", false);
list.add(new DatabaseConnectionField(TABSCHEMA));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.USER));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.PASSWD));
DB2NGDataStoreFactory factory = new DB2NGDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(DB2NGDataStoreFactory.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("tabschema"), properties.get(JDBCDataStoreFactory.DATABASE.key), properties.get(JDBCDataStoreFactory.HOST.key), properties.get(JDBCDataStoreFactory.PORT.key));
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
Aggregations