diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue index c4a928df4d..f577b79a4e 100644 --- a/apps/desktop/src/components/connection/ConnectionDialog.vue +++ b/apps/desktop/src/components/connection/ConnectionDialog.vue @@ -98,7 +98,7 @@ import { translateBackendError } from "@/i18n/backend-errors"; import { applyHiveKerberosSubmitConfig, hiveKerberosFormConfig, type HiveKerberosAuthMode } from "@/lib/database/hiveKerberosOptions"; import { hasCloudflareD1Credentials, isCloudflareD1Connection, normalizeCloudflareD1Connection } from "@/lib/connection/cloudflareD1"; import { buildElasticsearchExternalConfig, elasticsearchConnectionModeFromConfig, elasticsearchConnectivityCheckPathFromConfig, elasticsearchKibanaBasePathFromConfig, type ElasticsearchConnectionMode } from "@/lib/connection/elasticsearchKibanaProxy"; -import { gaussdbIdentifierQuoteStyle, setGaussdbIdentifierQuoteStyle, supportsGaussdbIdentifierQuoteStyle, type GaussdbIdentifierQuoteStyle } from "@/lib/database/jdbcDialect"; +import { GAUSSDB_M_JDBC_DRIVER_CLASS, gaussdbConnectionMode, gaussdbIdentifierQuoteStyle, setGaussdbConnectionMode, setGaussdbIdentifierQuoteStyle, supportsGaussdbIdentifierQuoteStyle, type GaussdbConnectionMode, type GaussdbIdentifierQuoteStyle } from "@/lib/database/jdbcDialect"; import { normalizeStoredConnectionDatabase } from "@/lib/database/sqliteNamespace"; type DbOption = { value: string; label: string }; @@ -452,6 +452,15 @@ function sshLayersForConfig(config: LegacyConnectionConfig): SshTunnelConfig[] { const form = ref(defaultForm()); const noteTextareaRef = ref(null); +const showGaussdbConnectionMode = computed(() => form.value.db_type === "gaussdb"); +const gaussdbDriverMode = computed({ + get: () => gaussdbConnectionMode(form.value), + set: (mode) => { + setGaussdbConnectionMode(form.value, mode); + resetTestState(); + }, +}); +const isGaussdbMJdbcConnection = computed(() => gaussdbDriverMode.value === "m-jdbc"); const showGaussdbIdentifierQuoteStyle = computed(() => supportsGaussdbIdentifierQuoteStyle(form.value)); const gaussdbQuoteStyle = computed({ get: () => gaussdbIdentifierQuoteStyle(form.value), @@ -1571,6 +1580,17 @@ async function ensureRequiredJdbcxDriverInstalled(config: ConnectionConfig): Pro } } +async function ensureRequiredGaussdbMJdbcRuntime(config: ConnectionConfig): Promise { + if (gaussdbConnectionMode(config) !== "m-jdbc") return; + if (!(config.jdbc_driver_paths ?? []).length) { + throw new Error(t("connection.gaussdbMJdbcDriverRequired")); + } + const status = await api.jdbcPluginStatus(); + if (status.installed && status.compatible) return; + testResult.value = { ok: true, message: t("connection.gaussdbMJdbcPluginInstalling") }; + await api.installJdbcPlugin(); +} + async function installSqlServerLegacyCompatibilityComponentIfNeeded(): Promise { if (await api.isAgentInstalled(SQLSERVER_LEGACY_COMPATIBILITY_DRIVER_KEY)) return true; @@ -1976,7 +1996,7 @@ watch( name: config.name, note: config.note || "", db_type: oceanbasePatch?.db_type || profileConfig?.type || config.db_type, - driver_profile: oceanbasePatch?.driver_profile || profile, + driver_profile: oceanbasePatch?.driver_profile || config.driver_profile || profile, driver_label: config.driver_label || oceanbasePatch?.driver_label || driverProfiles[profile]?.label || config.db_type, url_params: config.url_params || "", agent_java_options: config.agent_java_options || [], @@ -2916,6 +2936,7 @@ async function testConnection() { try { config = connectionConfigForSubmit(editingId.value || draftTestConnectionId.value); await ensureRequiredAgentDriverInstalled(config); + await ensureRequiredGaussdbMJdbcRuntime(config); await ensureRequiredJdbcxDriverInstalled(config); const result = await testConnectionWithTimeout(config, runId); if (runId !== testRunId) return; @@ -3352,7 +3373,7 @@ function connectionConfigForSubmit(id: string, generatedName = ""): ConnectionCo } else { config.ca_cert_path = config.ca_cert_path?.trim() || ""; } - if (jdbcBackedDatabaseTypes.has(config.db_type)) { + if (jdbcBackedDatabaseTypes.has(config.db_type) || gaussdbConnectionMode(config) === "m-jdbc") { if (config.db_type === "jdbc") { if (config.driver_profile === "dremio") { applyDremioJdbcMetadata(config); @@ -3370,12 +3391,19 @@ function connectionConfigForSubmit(id: string, generatedName = ""): ConnectionCo config.connection_string = undefined; config.jdbc_driver_class = config.jdbc_driver_class?.trim() || "io.prestosql.jdbc.PrestoDriver"; applyPrestoSqlBuiltinDriverPathsIfAvailable(); + } else if (config.db_type === "gaussdb") { + config.connection_string = undefined; + config.jdbc_driver_class = GAUSSDB_M_JDBC_DRIVER_CLASS; } config.jdbc_driver_class = config.jdbc_driver_class?.trim() || undefined; config.jdbc_driver_paths = jdbcDriverPathsInput.value .split(/\r?\n/) .map((path) => path.trim()) .filter(Boolean); + } else if (config.db_type === "gaussdb") { + config.connection_string = undefined; + config.jdbc_driver_class = undefined; + config.jdbc_driver_paths = []; } if (config.db_type === "h2") { const h2Mode = connectionUrlInput.value.trim() ? h2ConnectionModeForConfig(config) : h2ConnectionMode.value; @@ -3948,9 +3976,13 @@ async function copyConnectionErrorDetail() { } } +function openJdbcDriverManager() { + emit("openDriverStore", { target: "tab", tab: "jdbc" }); +} + function openJdbcDriverManagerFromError() { showConnectionErrorDialog.value = false; - emit("openDriverStore", { target: "tab", tab: "jdbc" }); + openJdbcDriverManager(); } function resetForm() { @@ -4276,11 +4308,13 @@ async function save() { if (editingId.value) { const updated = withSavedDatabaseInfo(connectionConfigForSubmit(editingId.value), databaseInfoForSave); await ensureRequiredAgentDriverInstalled(updated); + await ensureRequiredGaussdbMJdbcRuntime(updated); await store.updateConnection(updated); store.stopEditing(); } else { const config = withSavedDatabaseInfo(connectionConfigForSubmit(draftTestConnectionId.value), databaseInfoForSave); await ensureRequiredAgentDriverInstalled(config); + await ensureRequiredGaussdbMJdbcRuntime(config); await store.addConnection(config); draftTestConnectionId.value = uuid(); if (config.db_type === "jdbc") { @@ -6562,6 +6596,60 @@ function openExternalUrl(url: string) {
+
+ +
+ +

+ {{ isGaussdbMJdbcConnection ? t("connection.gaussdbConnectionModeMJdbcHint") : t("connection.gaussdbConnectionModeNativeHint") }} +

+
+
+
+ +
+ +
+