Search in sources :

Example 1 with DBPDataSourceURLProvider

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

the class PostgreDataSourceProvider method getConnectionURL.

@Override
public String getConnectionURL(DBPDriver driver, DBPConnectionConfiguration connectionInfo) {
    DBAAuthModel authModel = connectionInfo.getAuthModel();
    if (authModel instanceof DBPDataSourceURLProvider) {
        return ((DBPDataSourceURLProvider) authModel).getConnectionURL(driver, connectionInfo);
    }
    PostgreServerType serverType = PostgreUtils.getServerType(driver);
    if (serverType.supportsCustomConnectionURL()) {
        return JDBCURL.generateUrlByTemplate(driver, connectionInfo);
    }
    StringBuilder url = new StringBuilder();
    url.append("jdbc:postgresql://");
    url.append(connectionInfo.getHostName());
    if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
        url.append(":").append(connectionInfo.getHostPort());
    }
    url.append("/");
    if (!CommonUtils.isEmpty(connectionInfo.getDatabaseName())) {
        url.append(connectionInfo.getDatabaseName());
    }
    // }
    return url.toString();
}
Also used : PostgreServerType(org.jkiss.dbeaver.ext.postgresql.model.impls.PostgreServerType) DBPDataSourceURLProvider(org.jkiss.dbeaver.model.DBPDataSourceURLProvider) DBAAuthModel(org.jkiss.dbeaver.model.auth.DBAAuthModel)

Example 2 with DBPDataSourceURLProvider

use of org.jkiss.dbeaver.model.DBPDataSourceURLProvider in project dbeaver by dbeaver.

the class PostgreDataSourceProvider method getConnectionURL.

@Override
public String getConnectionURL(DBPDriver driver, DBPConnectionConfiguration connectionInfo) {
    DBAAuthModel authModel = connectionInfo.getAuthModel();
    if (authModel instanceof DBPDataSourceURLProvider) {
        return ((DBPDataSourceURLProvider) authModel).getConnectionURL(driver, connectionInfo);
    }
    PostgreServerType serverType = PostgreUtils.getServerType(driver);
    if (serverType.supportsCustomConnectionURL()) {
        return JDBCURL.generateUrlByTemplate(driver, connectionInfo);
    }
    StringBuilder url = new StringBuilder();
    url.append("jdbc:postgresql://");
    url.append(connectionInfo.getHostName());
    if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
        url.append(":").append(connectionInfo.getHostPort());
    }
    url.append("/");
    if (!CommonUtils.isEmpty(connectionInfo.getDatabaseName())) {
        url.append(connectionInfo.getDatabaseName());
    }
    // }
    return url.toString();
}
Also used : PostgreServerType(org.jkiss.dbeaver.ext.postgresql.model.impls.PostgreServerType) DBPDataSourceURLProvider(org.jkiss.dbeaver.model.DBPDataSourceURLProvider) DBAAuthModel(org.jkiss.dbeaver.model.auth.DBAAuthModel)

Aggregations

PostgreServerType (org.jkiss.dbeaver.ext.postgresql.model.impls.PostgreServerType)2 DBPDataSourceURLProvider (org.jkiss.dbeaver.model.DBPDataSourceURLProvider)2 DBAAuthModel (org.jkiss.dbeaver.model.auth.DBAAuthModel)2