Search in sources :

Example 1 with OracleNGDataStoreFactory

use of org.geotools.data.oracle.OracleNGDataStoreFactory 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;
}
Also used : DatabaseConnectionField(com.sldeditor.common.data.DatabaseConnectionField) OracleNGDataStoreFactory(org.geotools.data.oracle.OracleNGDataStoreFactory) ArrayList(java.util.ArrayList) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection)

Aggregations

DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)1 DatabaseConnectionField (com.sldeditor.common.data.DatabaseConnectionField)1 ArrayList (java.util.ArrayList)1 OracleNGDataStoreFactory (org.geotools.data.oracle.OracleNGDataStoreFactory)1