use of com.sldeditor.common.data.DatabaseConnectionField 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;
}
use of com.sldeditor.common.data.DatabaseConnectionField 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;
}
use of com.sldeditor.common.data.DatabaseConnectionField 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;
}
use of com.sldeditor.common.data.DatabaseConnectionField in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createOracle.
/**
* Creates a new DatabaseConnection object for Oracle.
*
* @return the database connection
*/
public static DatabaseConnection createOracle() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(OracleNGDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(OracleNGDataStoreFactory.PORT));
list.add(new DatabaseConnectionField(OracleNGDataStoreFactory.SCHEMA));
list.add(new DatabaseConnectionField(OracleNGDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(OracleNGDataStoreFactory.USER));
list.add(new DatabaseConnectionField(OracleNGDataStoreFactory.PASSWD));
OracleNGDataStoreFactory factory = new OracleNGDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(OracleNGDataStoreFactory.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(OracleNGDataStoreFactory.SCHEMA.key), properties.get(OracleNGDataStoreFactory.DATABASE.key), properties.get(OracleNGDataStoreFactory.HOST.key), properties.get(OracleNGDataStoreFactory.PORT.key));
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
use of com.sldeditor.common.data.DatabaseConnectionField in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createSpatiaLite.
/**
* Creates a new DatabaseConnection object for a GeoPackage.
*
* @return the database connection
*/
public static DatabaseConnection createSpatiaLite() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(SpatiaLiteDataStoreFactory.DATABASE));
FileNameExtensionFilter filter = new FileNameExtensionFilter(Localisation.getString(DatabaseConnector.class, "DatabaseConnectorGeoPkg.fileExtension") + " (*." + SPATIALITE_FILE_EXTENSION + ")", SPATIALITE_FILE_EXTENSION);
list.add(new DatabaseConnectionField(SpatiaLiteDataStoreFactory.USER, filter));
SpatiaLiteDataStoreFactory factory = new SpatiaLiteDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(SpatiaLiteDataStoreFactory.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