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