Skip to content

Commit

Permalink
CB-5574. Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisSinelnikov committed Jan 15, 2025
1 parent e0f4bf0 commit 6ba1a71
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
import org.jkiss.dbeaver.model.exec.DBCConnectException;
import org.jkiss.dbeaver.model.rm.RMProjectType;
import org.jkiss.dbeaver.model.websocket.WSConstants;
import org.jkiss.dbeaver.model.websocket.event.datasource.WSDataSourceProperty;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.runtime.jobs.ConnectionTestJob;
import org.jkiss.dbeaver.utils.RuntimeUtils;
import org.jkiss.utils.CommonUtils;
Expand Down Expand Up @@ -294,6 +296,7 @@ public WebConnectionInfo testConnection(
@NotNull WebConnectionConfig connectionConfig,
DataSourceDescriptor testDataSource
) throws DBWebException {
validateDriverLibrariesPresence(testDataSource);
webSession.provideAuthParameters(webSession.getProgressMonitor(),
testDataSource,
testDataSource.getConnectionConfiguration());
Expand All @@ -306,6 +309,12 @@ public WebConnectionInfo testConnection(
});
ct.run(webSession.getProgressMonitor());
if (ct.getConnectError() != null) {
if (ct.getConnectError() instanceof DBCConnectException error) {
Throwable rootCause = CommonUtils.getRootCause(error);
if (rootCause instanceof ClassNotFoundException) {
throwDriverNotFoundException(testDataSource);
}
}
throw new DBWebException("Connection failed", ct.getConnectError());
}
WebConnectionInfo connectionInfo = new WebConnectionInfo(webSession, testDataSource);
Expand Down Expand Up @@ -390,4 +399,17 @@ public WebConnectionInfo getConnectionState(
public WebPropertyInfo[] getExternalInfo(WebSession session) {

Check warning on line 399 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/ConnectionControllerCE.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/ConnectionControllerCE.java#L399

Missing a Javadoc comment.
return null;
}


private void validateDriverLibrariesPresence(@NotNull DBPDataSourceContainer container) throws DBWebException {
if (!DBWorkbench.isDistributed() && container.getDriver().needsExternalDependencies()) {
throwDriverNotFoundException(container);
}
}

@NotNull
private static String throwDriverNotFoundException(@NotNull DBPDataSourceContainer container) throws DBWebException {
throw new DBWebException("Driver files for %s are not found. Please ask the administrator to download it."
.formatted(container.getDriver().getName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@ public WebConnectionInfo copyConnectionFromNode(

@Override
public WebConnectionInfo testConnection(
@NotNull WebSession webSession, @Nullable String projectId, @NotNull WebConnectionConfig connectionConfig
@NotNull WebSession webSession,
@Nullable String projectId,
@NotNull WebConnectionConfig connectionConfig
) throws DBWebException {
DataSourceDescriptor dataSourceDescriptor = WebAppUtils.getWebApplication().getConnectionController()
.prepareTestConnection(webSession, projectId, connectionConfig);
Expand Down

0 comments on commit 6ba1a71

Please sign in to comment.