Search in sources :

Example 1 with DBPDriver

use of org.jkiss.dbeaver.model.connection.DBPDriver in project dbeaver by serge-rider.

the class WMIDataSourceProvider method openDataSource.

@NotNull
@Override
public DBPDataSource openDataSource(@NotNull DBRProgressMonitor monitor, @NotNull DBPDataSourceContainer container) throws DBException {
    if (!libLoaded) {
        DBPDriver driver = container.getDriver();
        driver.loadDriver(monitor);
        loadNativeLib(driver);
        libLoaded = true;
    }
    return new WMIDataSource(container);
}
Also used : DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) WMIDataSource(org.jkiss.dbeaver.ext.wmi.model.WMIDataSource) NotNull(org.jkiss.code.NotNull)

Example 2 with DBPDriver

use of org.jkiss.dbeaver.model.connection.DBPDriver in project dbeaver by serge-rider.

the class DataTypeProviderRegistry method findTransformers.

@Override
public List<AttributeTransformerDescriptor> findTransformers(DBPDataSource dataSource, DBSTypedObject typedObject, Boolean custom) {
    DBPDriver driver = dataSource.getContainer().getDriver();
    if (!(driver instanceof DriverDescriptor)) {
        log.warn("Bad datasource specified (driver is not recognized by registry) - " + dataSource);
        return null;
    }
    DataSourceProviderDescriptor dsProvider = ((DriverDescriptor) driver).getProviderDescriptor();
    // Find in default providers
    List<AttributeTransformerDescriptor> result = null;
    for (AttributeTransformerDescriptor descriptor : dataTypeTransformers) {
        if ((custom == null || custom == descriptor.isCustom()) && ((!descriptor.isGlobal() && descriptor.supportsDataSource(dataSource, dsProvider) && descriptor.supportsType(typedObject)) || (descriptor.isGlobal() && descriptor.supportsType(typedObject)))) {
            if (result == null) {
                result = new ArrayList<>();
            }
            result.add(descriptor);
        }
    }
    return result;
}
Also used : DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor) DBDAttributeTransformerDescriptor(org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor)

Example 3 with DBPDriver

use of org.jkiss.dbeaver.model.connection.DBPDriver in project dbeaver by serge-rider.

the class ConfigImportWizardPageCustomConnections method loadConnections.

@Override
protected void loadConnections(ImportData importData) throws DBException {
    setErrorMessage(null);
    ConfigImportWizardCustom wizard = (ConfigImportWizardCustom) getWizard();
    final DBPDriver driver = wizard.getDriver();
    ImportDriverInfo driverInfo = new ImportDriverInfo(driver.getId(), driver.getName(), driver.getSampleURL(), driver.getDriverClassName());
    importData.addDriver(driverInfo);
    File inputFile = wizard.getInputFile();
    try (InputStream is = new FileInputStream(inputFile)) {
        try (Reader reader = new InputStreamReader(is, wizard.getInputFileEncoding())) {
            if (wizard.getImportType() == ConfigImportWizardCustom.ImportType.CSV) {
                importCSV(importData, driverInfo, reader);
            } else {
                importXML(importData, driverInfo, reader);
            }
        }
    } catch (Exception e) {
        setErrorMessage(e.getMessage());
    }
}
Also used : DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) ImportDriverInfo(org.jkiss.dbeaver.ext.import_config.wizards.ImportDriverInfo) CSVReader(au.com.bytecode.opencsv.CSVReader) XMLException(org.jkiss.utils.xml.XMLException) DBException(org.jkiss.dbeaver.DBException)

Example 4 with DBPDriver

use of org.jkiss.dbeaver.model.connection.DBPDriver in project dbeaver by serge-rider.

the class MySQLConnectionPage method loadSettings.

@Override
public void loadSettings() {
    super.loadSettings();
    DBPDriver driver = getSite().getDriver();
    if (!activated) {
        // There is a bug in Eclipse which leads to SWTException after wizard image change
        if (driver != null && driver.getId().equalsIgnoreCase(MySQLConstants.DRIVER_ID_MARIA_DB)) {
            setImageDescriptor(MARIADB_LOGO_IMG);
        } else {
            setImageDescriptor(MYSQL_LOGO_IMG);
        }
    }
    // Load values from new connection info
    DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
    if (hostText != null) {
        if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
            hostText.setText(connectionInfo.getHostName());
        } else {
            hostText.setText(MySQLConstants.DEFAULT_HOST);
        }
    }
    if (portText != null) {
        if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
            portText.setText(String.valueOf(connectionInfo.getHostPort()));
        } else if (site.getDriver().getDefaultPort() != null) {
            portText.setText(site.getDriver().getDefaultPort());
        } else {
            portText.setText("");
        }
    }
    if (dbText != null) {
        dbText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
    }
    if (usernameText != null) {
        usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
    }
    if (passwordText != null) {
        passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
    }
    homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
    activated = true;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver)

Example 5 with DBPDriver

use of org.jkiss.dbeaver.model.connection.DBPDriver in project dbeaver by serge-rider.

the class GenericSQLDialect method initDriverSettings.

public void initDriverSettings(JDBCDataSource dataSource, JDBCDatabaseMetaData metaData) {
    super.initDriverSettings(dataSource, metaData);
    DBPDriver driver = dataSource.getContainer().getDriver();
    this.scriptDelimiter = CommonUtils.toString(driver.getDriverParameter(GenericConstants.PARAM_SCRIPT_DELIMITER));
    this.scriptDelimiterRedefiner = CommonUtils.toString(driver.getDriverParameter(GenericConstants.PARAM_SCRIPT_DELIMITER_REDEFINER));
    this.legacySQLDialect = CommonUtils.toBoolean(driver.getDriverParameter(GenericConstants.PARAM_LEGACY_DIALECT));
    this.suportsUpsert = ((GenericDataSource) dataSource).getMetaModel().supportsUpsertStatement();
    if (this.suportsUpsert) {
        addSQLKeyword("UPSERT");
    }
    this.quoteReservedWords = CommonUtils.getBoolean(driver.getDriverParameter(GenericConstants.PARAM_QUOTE_RESERVED_WORDS), true);
    this.testSQL = CommonUtils.toString(driver.getDriverParameter(GenericConstants.PARAM_QUERY_PING));
    if (CommonUtils.isEmpty(this.testSQL)) {
        this.testSQL = CommonUtils.toString(driver.getDriverParameter(GenericConstants.PARAM_QUERY_GET_ACTIVE_DB));
    }
    this.dualTable = CommonUtils.toString(driver.getDriverParameter(GenericConstants.PARAM_DUAL_TABLE));
    if (this.dualTable.isEmpty()) {
        this.dualTable = null;
    }
}
Also used : DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver)

Aggregations

DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)6 DataSourceProviderDescriptor (org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)2 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)2 CSVReader (au.com.bytecode.opencsv.CSVReader)1 NotNull (org.jkiss.code.NotNull)1 Nullable (org.jkiss.code.Nullable)1 DBException (org.jkiss.dbeaver.DBException)1 ImportDriverInfo (org.jkiss.dbeaver.ext.import_config.wizards.ImportDriverInfo)1 WMIDataSource (org.jkiss.dbeaver.ext.wmi.model.WMIDataSource)1 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)1 DBDAttributeTransformerDescriptor (org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor)1 XMLException (org.jkiss.utils.xml.XMLException)1