Search in sources :

Example 11 with DatabaseConnectionField

use of com.sldeditor.common.data.DatabaseConnectionField 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

DatabaseConnectionField (com.sldeditor.common.data.DatabaseConnectionField)11 DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)10 ArrayList (java.util.ArrayList)10 File (java.io.File)4 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)2 Param (org.geotools.data.DataAccessFactory.Param)2 DatabaseConnectionName (com.sldeditor.tool.dbconnectionlist.DatabaseConnectionName)1 HashMap (java.util.HashMap)1 JTextField (javax.swing.JTextField)1 DB2NGDataStoreFactory (org.geotools.data.db2.DB2NGDataStoreFactory)1 H2DataStoreFactory (org.geotools.data.h2.H2DataStoreFactory)1 MySQLDataStoreFactory (org.geotools.data.mysql.MySQLDataStoreFactory)1 OracleNGDataStoreFactory (org.geotools.data.oracle.OracleNGDataStoreFactory)1 PostgisNGDataStoreFactory (org.geotools.data.postgis.PostgisNGDataStoreFactory)1 SpatiaLiteDataStoreFactory (org.geotools.data.spatialite.SpatiaLiteDataStoreFactory)1 JDTSSQLServerJNDIDataStoreFactory (org.geotools.data.sqlserver.jtds.JDTSSQLServerJNDIDataStoreFactory)1 TeradataDataStoreFactory (org.geotools.data.teradata.TeradataDataStoreFactory)1 GeoPkgDataStoreFactory (org.geotools.geopkg.GeoPkgDataStoreFactory)1 Test (org.junit.Test)1