Search in sources :

Example 1 with TeradataDataStoreFactory

use of org.geotools.data.teradata.TeradataDataStoreFactory in project sldeditor by robward-scisys.

the class DatabaseConnectionFactory method createTeradata.

/**
 * Creates a new DatabaseConnection object for Teradata.
 *
 * @return the database connection
 */
public static DatabaseConnection createTeradata() {
    List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
    list.add(new DatabaseConnectionField(TeradataDataStoreFactory.HOST));
    list.add(new DatabaseConnectionField(TeradataDataStoreFactory.PORT));
    list.add(new DatabaseConnectionField(TeradataDataStoreFactory.DATABASE));
    list.add(new DatabaseConnectionField(TeradataDataStoreFactory.USER));
    list.add(new DatabaseConnectionField(TeradataDataStoreFactory.SCHEMA));
    list.add(new DatabaseConnectionField(TeradataDataStoreFactory.PASSWD));
    TeradataDataStoreFactory factory = new TeradataDataStoreFactory();
    DatabaseConnection databaseConnection = new DatabaseConnection(TeradataDataStoreFactory.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(TeradataDataStoreFactory.SCHEMA.key), properties.get(TeradataDataStoreFactory.DATABASE.key), properties.get(TeradataDataStoreFactory.HOST.key), properties.get(TeradataDataStoreFactory.PORT.key));
            for (int i = 0; i < noOfTimesDuplicated; i++) {
                connectionName = duplicatePrefix + connectionName;
            }
            return connectionName;
        }
    });
    return databaseConnection;
}
Also used : DatabaseConnectionField(com.sldeditor.common.data.DatabaseConnectionField) ArrayList(java.util.ArrayList) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) TeradataDataStoreFactory(org.geotools.data.teradata.TeradataDataStoreFactory)

Aggregations

DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)1 DatabaseConnectionField (com.sldeditor.common.data.DatabaseConnectionField)1 ArrayList (java.util.ArrayList)1 TeradataDataStoreFactory (org.geotools.data.teradata.TeradataDataStoreFactory)1