use of org.geotools.data.h2.H2DataStoreFactory in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createH2.
/**
* Creates a new DatabaseConnection object for H2.
*
* @return the database connection
*/
public static DatabaseConnection createH2() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(H2DataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(H2DataStoreFactory.USER));
H2DataStoreFactory factory = new H2DataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(H2DataStoreFactory.DBTYPE, factory.getDisplayName(), false, list, new DatabaseConnectionName() {
@Override
public String getConnectionName(String duplicatePrefix, int noOfTimesDuplicated, Map<String, String> properties) {
String connectionName = Localisation.getString(DatabaseConnectionFactory.class, "common.notSet");
String databaseName = properties.get(JDBCDataStoreFactory.DATABASE.key);
if (databaseName != null) {
File f = new File(databaseName);
if (f.isFile()) {
connectionName = f.getName();
}
}
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
Aggregations