feat(database): select a JDBC driver from a database preset (#4607)

The General tab of a named database preset lists its built-in driver and the local JDBC profiles associated with that preset, so a local driver no longer requires switching the type to Custom JDBC; the type and tree icon stay. Manage Drivers and Go to Driver open the profile manager scoped to that type. A connection refuses a profile associated with another preset, and a JDBC password is kept apart from a Snowflake key-pair passphrase when switching transports.

Closes #4564

Co-authored-by: principalwater <67874880+principalwater@users.noreply.github.com>
This commit is contained in:
Vladislav Kuzmin
2026-11-22 00:37:23 +08:00
committed by GitHub
parent 4bc68d27cc
commit aaab9a5dc6
15 changed files with 1154 additions and 163 deletions
+10 -1
View File
@@ -22,6 +22,9 @@ const LIMIT: usize = 16 * 1024 * 1024;
pub struct DbJdbcDriver {
pub id: String,
pub name: String,
/// Data source preset id; absent for a generic JDBC profile.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vendor: Option<String>,
pub jars: Vec<String>,
pub class_name: String,
pub url_template: String,
@@ -146,7 +149,7 @@ impl DbManager {
fn jdbc_approval(&self, source: &DataSource) -> IdeResult<(PathBuf, String)> {
let registry = self.jdbc_registry()?;
let key = serde_json::to_vec(&(&self.root, &source.id)).map_err(|e| IdeError::internal(e.to_string()))?;
let settings = serde_json::to_vec(&(
let mut settings = serde_json::to_vec(&(
&source.jdbc_driver,
&source.url,
&source.user,
@@ -155,6 +158,9 @@ impl DbManager {
&source.options,
))
.map_err(|e| IdeError::internal(e.to_string()))?;
if self.jdbc_password_isolated(source) {
settings.extend_from_slice(b"\0jdbc-password");
}
Ok((
registry.with_file_name("jdbc-approvals").join(blake3::hash(&key).to_hex().as_str()),
blake3::hash(&settings).to_hex().to_string(),
@@ -195,6 +201,9 @@ impl DbManager {
.into_iter()
.find(|d| d.id == source.jdbc_driver)
.ok_or_else(|| IdeError::invalid("Select an installed JDBC driver profile"))?;
if !source.vendor.is_empty() && driver.vendor.as_deref() != Some(source.vendor.as_str()) {
return Err(IdeError::invalid("The JDBC driver profile is not associated with this data source type"));
}
JdbcPool::connect(source, password, driver, self.jdbc_registry()?.with_file_name("jdbc"))
.await
.map(Box::new)
+116 -7
View File
@@ -475,6 +475,29 @@ impl DbManager {
}
}
fn non_password_snowflake(source: &DataSource) -> Option<DbSnowflake> {
let settings = match source.driver {
DbDriver::Snowflake => source.resolved().map(|source| source.snowflake()).unwrap_or_default(),
DbDriver::Jdbc => source.snowflake.clone()?,
_ => return None,
};
(settings.auth != DbSnowflakeAuth::Password).then_some(settings)
}
fn jdbc_password_isolated(&self, source: &DataSource) -> bool {
source.driver == DbDriver::Jdbc
&& (Self::non_password_snowflake(source).is_some()
|| self
.sources()
.unwrap_or_default()
.iter()
.any(|stored| stored.id == source.id && Self::non_password_snowflake(stored).is_some()))
}
fn password_key(&self, source: &DataSource) -> String {
if self.jdbc_password_isolated(source) { secrets::jdbc_key(&source.id) } else { source.id.clone() }
}
/// The connection settings of target `target` ([`DataSource::resolved`]), with
/// its database for `<id>:<database>`.
pub fn source(&self, target: &str) -> IdeResult<DataSource> {
@@ -497,13 +520,19 @@ impl DbManager {
/// Saves the data source list; connections of removed or changed sources are closed.
/// Global ones (`global`) go to the app-wide list, the others to the project's.
pub async fn save_sources(&self, sources: Vec<DataSource>) -> IdeResult<()> {
pub async fn save_sources(&self, mut sources: Vec<DataSource>) -> IdeResult<()> {
if sources.iter().any(|s| s.global && s.plugin_owner.is_some()) {
return Err(IdeError::invalid("plugin-owned data sources must stay project-scoped"));
}
let old = {
let _guard = plugin::EDIT.lock();
let old = self.sources().unwrap_or_default();
for source in sources.iter_mut().filter(|s| s.driver == DbDriver::Jdbc) {
// Retain the credential scope even when URL-only settings supplied the old authenticator.
if let Some(settings) = old.iter().find(|s| s.id == source.id).and_then(Self::non_password_snowflake) {
source.snowflake = Some(settings);
}
}
let (global, project): (Vec<_>, Vec<_>) = sources.iter().cloned().partition(|s| s.global);
match &self.global {
// Rewritten only when it changes: other projects' windows edit the same file.
@@ -524,7 +553,8 @@ impl DbManager {
match sources.iter().find(|s| s.id == o.id) {
Some(n) if *n == o => {}
gone_or_changed => {
let keys = [o.id.clone(), secrets::ssh_key(&o.id), Self::sso_credential(&o.id)];
let keys =
[o.id.clone(), secrets::jdbc_key(&o.id), secrets::ssh_key(&o.id), Self::sso_credential(&o.id)];
match gone_or_changed {
None => {
self.catalogs.forget(&o.id);
@@ -590,7 +620,12 @@ impl DbManager {
/// Remembers `password` for the session, and in the saved passwords when
/// the data source saves passwords (`None` forgets it).
pub async fn set_password(&self, id: &str, password: Option<String>, save: bool) -> IdeResult<()> {
self.remember(id, id.to_owned(), password, save).await
let source = self.sources()?.into_iter().find(|s| s.id == id);
let (store, key) = match source.as_ref() {
Some(source) => (self.store_of(source), self.password_key(source)),
None => (&self.saved_passwords, id.to_owned()),
};
self.remember(store, key, password, save).await
}
/// [`DbManager::set_password`] for the SSH password / key passphrase.
@@ -602,10 +637,10 @@ impl DbManager {
self.ssh.set_secret(&c, secret, save);
return Ok(());
}
self.remember(id, secrets::ssh_key(id), secret, save).await
self.remember(self.saved_for(id), secrets::ssh_key(id), secret, save).await
}
async fn remember(&self, id: &str, key: String, secret: Option<String>, save: bool) -> IdeResult<()> {
async fn remember(&self, store: &SecretStore, key: String, secret: Option<String>, save: bool) -> IdeResult<()> {
match &secret {
Some(p) => {
self.session_passwords.lock().insert(key.clone(), p.clone());
@@ -614,7 +649,6 @@ impl DbManager {
self.session_passwords.lock().remove(&key);
}
}
let store = self.saved_for(id);
let result = match (secret, save) {
(Some(p), true) => store.set(&key, &p),
_ => {
@@ -640,7 +674,10 @@ impl DbManager {
}
async fn password(&self, source: &DataSource) -> Option<String> {
match self.secret(source, source.id.clone(), source.driver != DbDriver::Sqlite && source.save_password).await {
match self
.secret(source, self.password_key(source), source.driver != DbDriver::Sqlite && source.save_password)
.await
{
Some(p) => Some(p),
None => source.url_password(),
}
@@ -1763,6 +1800,78 @@ mod tests {
);
}
#[tokio::test]
async fn switching_from_snowflake_key_pair_keeps_the_jdbc_password_separate() -> IdeResult<()> {
let tmp = tempfile::tempdir()?;
let db = manager(tmp.path()).with_global_sources(tmp.path().join("global"));
let native = DataSource {
id: "snowflake".into(),
name: "Snowflake".into(),
driver: DbDriver::Snowflake,
save_password: true,
url_only: true,
url: "jdbc:snowflake://example.invalid/?authenticator=SNOWFLAKE_JWT".into(),
..Default::default()
};
db.save_sources(vec![native.clone()]).await?;
db.set_password(&native.id, Some("native-passphrase".into()), true).await?;
let jdbc = DataSource { driver: DbDriver::Jdbc, url: "jdbc:fixture:".into(), ..native.clone() };
// Test Connection can use the JDBC draft before the user saves it.
assert_eq!(db.password(&jdbc).await, None);
assert_eq!(db.password(&native).await.as_deref(), Some("native-passphrase"));
db.approve_jdbc_source(&jdbc)?;
db.save_sources(vec![jdbc.clone()]).await?;
assert_eq!(db.password(&db.source(&jdbc.id)?).await, None);
db.set_password(&jdbc.id, Some("jdbc-password".into()), true).await?;
let reopened = manager(tmp.path()).with_global_sources(tmp.path().join("global"));
let saved = reopened.source(&jdbc.id)?;
assert_eq!(reopened.password(&saved).await.as_deref(), Some("jdbc-password"));
let err = reopened.pool(&jdbc.id).await.err().expect("no JDBC profile installed");
assert!(err.message.contains("Select an installed JDBC driver profile"));
source::save(&reopened.root, std::slice::from_ref(&jdbc))?;
let err = reopened.pool(&jdbc.id).await.err().expect("edited settings need approval");
assert!(err.message.contains("Review this project's JDBC URL and properties"));
source::save(&reopened.root, std::slice::from_ref(&saved))?;
let global = DataSource { global: true, ..saved };
reopened.save_sources(vec![global.clone()]).await?;
assert_eq!(reopened.password(&reopened.source(&jdbc.id)?).await.as_deref(), Some("jdbc-password"));
let native = DataSource { global: true, ..native };
reopened.save_sources(vec![native.clone()]).await?;
assert_eq!(reopened.password(&native).await.as_deref(), Some("native-passphrase"));
reopened.save_sources(Vec::new()).await?;
assert_eq!(reopened.password(&native).await, None);
assert_eq!(reopened.password(&global).await, None);
Ok(())
}
#[tokio::test]
async fn switching_from_snowflake_password_keeps_the_password() -> IdeResult<()> {
let tmp = tempfile::tempdir()?;
let db = manager(tmp.path());
let native = DataSource {
id: "snowflake".into(),
name: "Snowflake".into(),
driver: DbDriver::Snowflake,
save_password: true,
url_only: true,
url: "jdbc:snowflake://example.invalid/?authenticator=snowflake".into(),
..Default::default()
};
db.save_sources(vec![native.clone()]).await?;
db.set_password(&native.id, Some("existing-password".into()), true).await?;
let jdbc = DataSource { driver: DbDriver::Jdbc, url: "jdbc:fixture:".into(), ..native };
assert_eq!(db.password(&jdbc).await.as_deref(), Some("existing-password"));
db.save_sources(vec![jdbc.clone()]).await?;
let reopened = manager(tmp.path());
assert_eq!(reopened.password(&reopened.source(&jdbc.id)?).await.as_deref(), Some("existing-password"));
Ok(())
}
#[tokio::test]
async fn moves_plaintext_passwords_of_older_versions_off_disk() {
let tmp = tempfile::tempdir().unwrap();
+5
View File
@@ -18,6 +18,11 @@ pub fn ssh_key(id: &str) -> String {
format!("{id}#ssh")
}
/// JDBC password when the original credential is a Snowflake passphrase or token.
pub fn jdbc_key(id: &str) -> String {
format!("{id}#jdbc")
}
fn file_key(project: &str, key: &str) -> String {
format!("{project}|{key}")
}
+41
View File
@@ -17,12 +17,14 @@ async fn jdbc_profiles_persist_and_project_files_cannot_start_drivers() -> IdeRe
db.save_jdbc_driver(DbJdbcDriver {
id: "fixture".into(),
name: "Test".into(),
vendor: None,
jars: vec![jar.display().to_string()],
class_name: "test.Driver".into(),
url_template: "jdbc:test:".into(),
})?;
let reopened = manager(tmp.path());
assert_eq!(reopened.jdbc_drivers()?[0].class_name, "test.Driver");
assert_eq!(reopened.jdbc_drivers()?[0].vendor, None);
let source = DataSource {
id: "local".into(),
name: "local".into(),
@@ -53,6 +55,40 @@ async fn jdbc_profiles_persist_and_project_files_cannot_start_drivers() -> IdeRe
Ok(())
}
#[tokio::test]
async fn named_jdbc_sources_persist_the_type_and_reject_a_profile_for_another_type() -> IdeResult<()> {
let tmp = tempfile::tempdir()?;
let jar = tmp.path().join("fixture.jar");
std::fs::write(&jar, [])?;
let db = manager(tmp.path());
db.save_jdbc_driver(DbJdbcDriver {
id: "fixture".into(),
name: "Test".into(),
vendor: Some("tidb".into()),
jars: vec![jar.display().to_string()],
class_name: "test.Driver".into(),
url_template: String::new(),
})?;
let source = DataSource {
id: "local".into(),
name: "local".into(),
driver: DbDriver::Jdbc,
vendor: "mariadb".into(),
jdbc_driver: "fixture".into(),
url: "jdbc:test:".into(),
..Default::default()
};
db.save_sources(vec![source]).await?;
let reopened = manager(tmp.path());
let source = reopened.source("local")?;
assert_eq!(reopened.jdbc_drivers()?[0].vendor.as_deref(), Some("tidb"));
assert_eq!(source.driver, DbDriver::Jdbc);
assert_eq!(source.vendor, "mariadb");
let err = reopened.test(&source, None, None).await.unwrap_err();
assert!(err.message.contains("not associated with this data source type"));
Ok(())
}
#[tokio::test]
#[ignore = "requires DUCKDB_JDBC_JAR and a local Java 17+ runtime"]
async fn duckdb_custom_driver_through_database_manager() -> IdeResult<()> {
@@ -63,6 +99,7 @@ async fn duckdb_custom_driver_through_database_manager() -> IdeResult<()> {
db.save_jdbc_driver(DbJdbcDriver {
id: "duck".into(),
name: "DuckDB".into(),
vendor: None,
jars: vec![jar],
class_name: "org.duckdb.DuckDBDriver".into(),
url_template: "jdbc:duckdb:".into(),
@@ -135,6 +172,7 @@ async fn clickhouse_vendor_driver_reads_catalog_and_results() -> IdeResult<()> {
db.save_jdbc_driver(DbJdbcDriver {
id: "clickhouse".into(),
name: "ClickHouse JDBC".into(),
vendor: Some("clickhouse".into()),
jars,
class_name: "com.clickhouse.jdbc.ClickHouseDriver".into(),
url_template: "jdbc:clickhouse://".into(),
@@ -143,6 +181,7 @@ async fn clickhouse_vendor_driver_reads_catalog_and_results() -> IdeResult<()> {
id: "test".into(),
name: "ClickHouse JDBC".into(),
driver: DbDriver::Jdbc,
vendor: "clickhouse".into(),
jdbc_driver: "clickhouse".into(),
url: format!("jdbc:clickhouse://127.0.0.1:{port}/default"),
user: "fixture".into(),
@@ -181,6 +220,7 @@ async fn unresponsive_driver_closes_before_reconnect() -> IdeResult<()> {
db.save_jdbc_driver(DbJdbcDriver {
id: "fixture".into(),
name: "Fixture".into(),
vendor: None,
jars: vec![std::env::var("JDBC_FIXTURE_JAR").unwrap()],
class_name: "ai.openidea.jdbc.SelfTest$Fixture".into(),
url_template: String::new(),
@@ -229,6 +269,7 @@ async fn a_lost_session_reconnects_on_the_next_statement() -> IdeResult<()> {
db.save_jdbc_driver(DbJdbcDriver {
id: "fixture".into(),
name: "Fixture".into(),
vendor: None,
jars: vec![std::env::var("JDBC_FIXTURE_JAR").unwrap()],
class_name: "ai.openidea.jdbc.SelfTest$Fixture".into(),
url_template: String::new(),
+6 -2
View File
@@ -23,9 +23,13 @@ Open it from **Tools › Database** or **View › Tool Windows › Database**. T
Presets set the default port and, where needed, SSL (for example Redshift, Neon and Supabase require SSL).
## Custom JDBC drivers
## JDBC drivers
Choose **New › Data Source › Custom JDBC**, then **Manage Drivers…**. Add a named profile with the vendor's driver JAR, any dependency JARs, the fully qualified driver class, and an optional JDBC URL template. OpenIDEA reads the driver classes declared in the selected JARs. You can choose a different class or enter its full name manually. Use `{host}`, `{port}`, `{database}` or `{file}` in a template to get matching connection fields, or edit the JDBC URL directly. Only import drivers you trust. OpenIDEA loads their code in a separate process using an installed Java 17 or newer runtime.
In a named data source's **General** tab, **Driver** defaults to **Built-in**. Use **Manage Drivers…** to view or add JDBC profiles for that data source type. Select the profile from **Driver** to use JDBC while keeping the source type and icon. **Go to Driver** opens the selected profile and its JAR list. Choose **New › Data Source › Custom JDBC** for databases without a preset, or open its **Manage Drivers…** to see all profiles and change their associated types.
Add a named profile with the vendor's driver JAR, any dependency JARs, the fully qualified driver class, and an optional JDBC URL template. OpenIDEA reads the driver classes declared in the selected JARs. You can choose a different class or enter its full name manually. Use `{host}`, `{port}`, `{database}` or `{file}` in a template to get matching connection fields, or edit the JDBC URL directly. Only import drivers you trust. OpenIDEA loads their code in a separate process using an installed Java 17 or newer runtime.
When switching to JDBC, configure TLS and driver-specific settings in the JDBC URL or **Advanced** properties. If the built-in source used an SSH tunnel, configure an equivalent route for the JDBC connection. JDBC uses auto-commit. Review the built-in startup script, default schema, and time zone, and configure equivalent settings supported by your JDBC driver or database. For enforced read-only access, use a database account with read-only privileges. Enter a separate JDBC password when converting a Snowflake source that used key pair, token, or browser authentication and your JDBC driver needs a password.
Select the profile, enter the vendor's JDBC URL, and use the **User**, **Password**, and **Advanced** fields for credentials and driver properties. The URL and Advanced properties are stored in the data source configuration. Put credentials in the password field to use the existing OS credential store. On Linux, saving a password requires a running Secret Service. You can also enter the password for the current session. The **Read-only** option asks the JDBC driver for a read-only connection. Use a database account with read-only privileges to enforce it. Cancelling a query keeps the session and its temporary tables when the driver stops the statement. If the driver does not respond within three seconds, OpenIDEA closes the session. A submitted statement can still finish on the server. **Test Connection** reports the database product and version. Schema, table and column browsing use JDBC metadata; the SQL console supports auto-commit queries and updates. Vendor-specific DDL, execution plans and table-grid writes are unavailable for custom drivers.
+6 -2
View File
@@ -23,9 +23,13 @@ description: "连接 SQL 数据库、浏览架构、在查询控制台中执行
预设会填好默认端口,必要时还会设置 SSL(例如 Redshift、Neon 和 Supabase 要求 SSL)。
## 自定义 JDBC 驱动
## JDBC 驱动
选择 **新建 › 数据源 › 自定义 JDBC**,然后选择 **管理驱动…**。为驱动配置命名,添加厂商提供的驱动 JAR 及依赖 JAR,填写完整的驱动类名和可选的 JDBC URL 模板。请仅导入可信来源的驱动。OpenIDEA 使用已安装的 Java 17 或更高版本运行时在单独的进程中加载驱动。 IDE 会读取 JAR 声明的驱动类,也支持手动输入完整类名。URL 模板支持 `{host}`、`{port}`、`{database}` 和 `{file}`,也可直接填写 JDBC URL。 URL 和高级属性会写入数据源配置,密码请填在密码栏,以使用系统凭据存储。“只读”选项会请求 JDBC 驱动建立只读连接。使用具备只读权限的数据库账号可强制限制写入。取消查询时,如果驱动停止了语句,会话及其临时表会保留。如果驱动在三秒内未响应,OpenIDEA 会关闭该会话。已提交的语句仍可能在服务器上完成。
在预设数据源的 **常规** 选项卡中,**驱动** 默认为 **内置**。通过 **管理驱动…** 查看或添加该数据源类型的 JDBC 驱动配置。在 **驱动** 中选中配置后,数据源会使用 JDBC,同时保留原有类型及图标。选择 **转到驱动** 可查看所选配置及其 JAR 文件。对于没有预设的数据库,请选择 **新建 › 数据源 › 自定义 JDBC**。也可以在其中选择 **管理驱动…** 查看所有配置并修改关联类型。
为驱动配置命名,添加厂商提供的驱动 JAR 及依赖 JAR,填写完整的驱动类名和可选的 JDBC URL 模板。请仅导入可信来源的驱动。OpenIDEA 使用已安装的 Java 17 或更高版本运行时在单独的进程中加载驱动。 IDE 会读取 JAR 声明的驱动类,也支持手动输入完整类名。URL 模板支持 `{host}`、`{port}`、`{database}` 和 `{file}`,也可直接填写 JDBC URL。 URL 和高级属性会写入数据源配置,密码请填在密码栏,以使用系统凭据存储。“只读”选项会请求 JDBC 驱动建立只读连接。使用具备只读权限的数据库账号可强制限制写入。取消查询时,如果驱动停止了语句,会话及其临时表会保留。如果驱动在三秒内未响应,OpenIDEA 会关闭该会话。已提交的语句仍可能在服务器上完成。
切换到 JDBC 时,请在 JDBC URL 或 **高级** 属性中配置 TLS 和驱动专用设置。如果内置数据源使用了 SSH 隧道,请为 JDBC 连接配置等效的网络路径。JDBC 使用自动提交。请检查内置驱动的启动脚本、默认模式和时区,并通过 JDBC 驱动或数据库配置相应的设置。要强制限制为只读访问,请使用具备只读权限的数据库账号。如果原 Snowflake 数据源使用密钥对、令牌或浏览器认证,且 JDBC 驱动需要密码,请单独设置 JDBC 密码。
选择驱动配置,填写厂商的 JDBC URL,在 **用户**、**密码** 和 **高级** 中设置凭据和驱动属性。通过密码字段输入的密码可以保存到系统凭据库。在 Linux 上,保存密码需要正在运行的 Secret Service;也可以仅为当前会话输入密码。**测试连接** 显示数据库产品和版本。可以通过 JDBC 元数据浏览模式、表和列,在 SQL 控制台中查询或以自动提交方式更新数据。自定义驱动不支持厂商特有的 DDL、执行计划或表格编辑。
+46 -7
View File
@@ -1,10 +1,20 @@
import type { DataSource_Deserialize, DbJdbcDriver } from "../src/bindings";
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
test("configures a local JDBC profile and a source through mocked IPC", async ({ workbench: page }, info) => {
test("uses a local JDBC profile for a named data source through mocked IPC", async ({ workbench: page }, info) => {
await stubDesktop(page);
await page.evaluate(async () => {
const drivers: Record<string, unknown>[] = [];
const drivers: Record<string, unknown>[] = [
{ id: "sqlite-fixture", vendor: "sqlite", name: "SQLite JDBC" },
{ id: "postgres-fixture", vendor: "postgres", name: "PostgreSQL JDBC" },
{ id: "legacy-fixture", name: "Legacy JDBC" },
{ id: "clickhouse-fixture", vendor: "clickhouse", name: "Existing ClickHouse JDBC" },
].map((driver) => ({
...driver,
jars: [`/mock/${driver.id}.jar`],
className: "org.example.jdbc.Driver",
urlTemplate: "jdbc:example:local",
}));
let sources: Record<string, unknown>[] = [];
Object.assign(window.__ipc.handlers, {
db_jdbc_drivers: () => drivers,
@@ -48,20 +58,30 @@ test("configures a local JDBC profile and a source through mocked IPC", async ({
});
});
const source = page.getByRole("dialog", { name: "New Data Source", exact: true });
await source.screenshot({
path: info.outputPath("mock-native-clickhouse-general.png"),
animations: "disabled",
});
await source.getByRole("tab", { name: "SSH/SSL", exact: true }).click();
await source.screenshot({
path: info.outputPath("mock-native-clickhouse-before-switch.png"),
animations: "disabled",
});
await source.getByRole("tab", { name: "General", exact: true }).click();
await source.getByRole("button", { name: "Data source type", exact: true }).click();
await page.getByRole("option", { name: "Custom JDBC", exact: true }).click();
await expect(source.getByRole("tab", { name: "SSH/SSL", exact: true })).toHaveCount(0);
await expect(source.locator("#db-url")).toHaveValue("");
await expect(source.getByRole("button", { name: "Connection driver", exact: true })).toHaveText("Built-in");
await source.getByRole("button", { name: "Manage Drivers…", exact: true }).click();
const profiles = page.getByRole("dialog", { name: "JDBC Driver Profiles", exact: true });
const profilesPicker = profiles.getByRole("button", { name: "JDBC driver profiles", exact: true });
await profilesPicker.click();
const choices = page.getByRole("listbox").getByRole("option");
await expect(choices).toHaveText(["Existing ClickHouse JDBC"]);
await page.screenshot({ path: info.outputPath("jdbc-manage-drivers-dropdown.png"), animations: "disabled" });
await page.getByRole("option", { name: "Existing ClickHouse JDBC", exact: true }).click();
await profiles.getByRole("button", { name: "Add…", exact: true }).click();
const editor = page.getByRole("dialog", { name: "Add JDBC Driver", exact: true });
const typePicker = editor.getByRole("button", { name: "Data source type", exact: true });
await expect(typePicker).toHaveText("ClickHouse");
await expect(typePicker).toBeDisabled();
await editor.getByLabel("Name:", { exact: true }).fill("Example local driver");
await editor.getByRole("button", { name: "Add JARs…", exact: true }).click();
await expect(editor.getByText("dependency.jar", { exact: true })).toBeVisible();
@@ -75,9 +95,11 @@ test("configures a local JDBC profile and a source through mocked IPC", async ({
await trust.screenshot({ path: info.outputPath("mock-jdbc-driver-trust.png"), animations: "disabled" });
await trust.getByRole("button", { name: "Trust and Save", exact: true }).click();
await profiles.getByRole("button", { name: "Use Driver", exact: true }).click();
await expect(source.getByRole("button", { name: "JDBC driver profile", exact: true })).toHaveText(
await expect(source.getByRole("button", { name: "Connection driver", exact: true })).toHaveText(
"Example local driver",
);
await expect(source.getByRole("button", { name: "Data source type", exact: true })).toHaveText("ClickHouse");
await expect(source.getByRole("tab", { name: "SSH/SSL", exact: true })).toHaveCount(0);
await source.getByLabel("Host:", { exact: true }).fill("example.invalid");
await source.getByLabel("Database:", { exact: true }).fill("catalog");
await expect(source.locator("#db-url")).toHaveValue("jdbc:example://example.invalid/catalog");
@@ -108,6 +130,7 @@ test("configures a local JDBC profile and a source through mocked IPC", async ({
password: "mock secret",
source: {
driver: "jdbc",
vendor: "clickhouse",
url,
user: "example-user",
readOnly: true,
@@ -122,6 +145,22 @@ test("configures a local JDBC profile and a source through mocked IPC", async ({
const driver = profile?.driver as DbJdbcDriver | undefined;
if (!saved || !driver) throw new Error("Expected the JDBC source and driver to be saved");
expect(saved.readOnly).toBe(true);
expect(driver.vendor).toBe("clickhouse");
expect(saved.vendor).toBe("clickhouse");
expect(saved.jdbcDriver).toBe(driver.id);
for (const key of ["jars", "className", "classpath", "exec", "password"]) expect(saved).not.toHaveProperty(key);
await page.evaluate(async () => {
const path = "/src/features/database/store.ts";
const { openSourceDialog, useDatabase } = await import(/* @vite-ignore */ path);
openSourceDialog(useDatabase.getState().sources[0]);
});
const reopened = page.getByRole("dialog", { name: "Data Source: Mock connection", exact: true });
await expect(reopened.getByRole("button", { name: "Data source type", exact: true })).toHaveText("ClickHouse");
await reopened.getByRole("button", { name: "Go to Driver", exact: true }).click();
await expect(profilesPicker).toHaveText("Example local driver");
await expect(profiles.getByText("dependency.jar", { exact: true })).toBeVisible();
await profilesPicker.click();
await expect(choices).toHaveText(["Existing ClickHouse JDBC", "Example local driver"]);
await page.screenshot({ path: info.outputPath("jdbc-go-to-driver-dropdown.png"), animations: "disabled" });
});
+17 -3
View File
@@ -338,7 +338,7 @@ export const commands = {
dbFinishTransaction: (id: string, commit: boolean) => typedError<null, IdeError>(__TAURI_INVOKE("db_finish_transaction", { id, commit })),
dbHistory: (id: string) => typedError<DbHistoryEntry[], IdeError>(__TAURI_INVOKE("db_history", { id })),
dbJdbcDriverClasses: (jars: string[]) => typedError<string[], IdeError>(__TAURI_INVOKE("db_jdbc_driver_classes", { jars })),
dbJdbcDrivers: () => typedError<DbJdbcDriver[], IdeError>(__TAURI_INVOKE("db_jdbc_drivers")),
dbJdbcDrivers: () => typedError<DbJdbcDriver_Serialize[], IdeError>(__TAURI_INVOKE("db_jdbc_drivers")),
dbObjectDdl: (id: string, schema: string, kind: DbObjectKind, name: string) => typedError<string, IdeError>(__TAURI_INVOKE("db_object_ddl", { id, schema, kind, name })),
dbRemoveHistory: (id: string, texts: string[] | null) => typedError<null, IdeError>(__TAURI_INVOKE("db_remove_history", { id, texts })),
dbRemoveJdbcDriver: (id: string) => typedError<null, IdeError>(__TAURI_INVOKE("db_remove_jdbc_driver", { id })),
@@ -348,7 +348,7 @@ export const commands = {
* in the desktop shell like [`db_export_file`]: the paths in `job` are local.
*/
dbRunTool: (request: RequestId, id: string, executable: string, job: DbToolJob, onOutput: Channel<DbToolLine[]>) => typedError<number | null, IdeError>(__TAURI_INVOKE("db_run_tool", { request, id, executable, job, onOutput })),
dbSaveJdbcDriver: (driver: DbJdbcDriver) => typedError<null, IdeError>(__TAURI_INVOKE("db_save_jdbc_driver", { driver })),
dbSaveJdbcDriver: (driver: DbJdbcDriver_Deserialize) => typedError<null, IdeError>(__TAURI_INVOKE("db_save_jdbc_driver", { driver })),
dbSaveSources: (sources: DataSource_Deserialize[]) => typedError<null, IdeError>(__TAURI_INVOKE("db_save_sources", { sources })),
dbSavedCatalog: (id: string) => typedError<{
databases?: DbCatalogDatabase[],
@@ -4625,9 +4625,23 @@ export type DbIntrospection = {
objectFilter?: string,
};
export type DbJdbcDriver = {
export type DbJdbcDriver = DbJdbcDriver_Serialize | DbJdbcDriver_Deserialize;
export type DbJdbcDriver_Deserialize = {
id: string,
name: string,
/** Data source preset id; absent for a generic JDBC profile. */
vendor?: string | null,
jars: string[],
className: string,
urlTemplate: string,
};
export type DbJdbcDriver_Serialize = {
id: string,
name: string,
/** Data source preset id; absent for a generic JDBC profile. */
vendor?: string | null,
jars: string[],
className: string,
urlTemplate: string,
+51 -17
View File
@@ -4,20 +4,14 @@ import { useTx } from "@/platform/i18n";
import { Button, Dialog, IconButton, Input, Select, T } from "@/ui";
import { baseName } from "./dumpTools";
import { newSourceId } from "./model";
import { VENDORS, vendorById } from "./vendors";
import styles from "./Database.module.css";
export function useJdbcDrivers(enabled: boolean) {
export function useJdbcDrivers() {
const [drivers, setDrivers] = useState<DbJdbcDriver[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [attempt, setAttempt] = useState(0);
const [wasEnabled, setWasEnabled] = useState(enabled);
if (wasEnabled !== enabled) {
setWasEnabled(enabled);
setDrivers(null);
setError(null);
}
useEffect(() => {
if (!enabled) return;
let active = true;
void call(commands.dbJdbcDrivers()).then(
(value) => {
@@ -30,7 +24,7 @@ export function useJdbcDrivers(enabled: boolean) {
return () => {
active = false;
};
}, [enabled, attempt]);
}, [attempt]);
const retry = () => {
setDrivers(null);
setError(null);
@@ -41,9 +35,15 @@ export function useJdbcDrivers(enabled: boolean) {
const blankDriver = (): DbJdbcDriver => ({ id: newSourceId(), name: "", jars: [], className: "", urlTemplate: "" });
const DRIVER_TYPES = [
{ value: "", label: "Custom JDBC only" },
...VENDORS.filter((v) => v.driver !== "jdbc").map((v) => ({ value: v.id, label: v.label, icon: v.icon })),
];
export function JdbcDriverProfiles({
drivers,
selected,
sourceVendor,
onSave,
onUse,
onRemove,
@@ -51,21 +51,24 @@ export function JdbcDriverProfiles({
}: {
drivers: DbJdbcDriver[];
selected: string;
sourceVendor?: string;
onSave: (driver: DbJdbcDriver) => void;
onUse?: (driver: DbJdbcDriver) => void;
onRemove: (id: string) => void;
onClose: () => void;
}) {
const tx = useTx();
const profiles = sourceVendor ? drivers.filter((d) => d.vendor === sourceVendor) : drivers;
const [selection, setSelection] = useState(
drivers.some((d) => d.id === selected) ? selected : (drivers[0]?.id ?? ""),
profiles.some((d) => d.id === selected) ? selected : (profiles[0]?.id ?? ""),
);
const [draft, setDraft] = useState<DbJdbcDriver | null>(null);
const [confirm, setConfirm] = useState<"trust" | "delete" | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [classes, setClasses] = useState<string[]>([]);
const current = drivers.find((d) => d.id === selection);
const current = profiles.find((d) => d.id === selection);
const changedType = draft && profiles.some((d) => d.id === draft.id && d.vendor && d.vendor !== draft.vendor);
const name = current?.name ?? "";
const set = (patch: Partial<DbJdbcDriver>) => setDraft((d) => d && { ...d, ...patch });
const classValid =
@@ -107,7 +110,12 @@ export function JdbcDriverProfiles({
if (!draft || !valid || busy) return;
setBusy(true);
setError(null);
const driver = { ...draft, name: draft.name.trim(), className: draft.className.trim() };
const driver = {
...draft,
...(sourceVendor && { vendor: sourceVendor }),
name: draft.name.trim(),
className: draft.className.trim(),
};
try {
await call(commands.dbSaveJdbcDriver(driver));
onSave(driver);
@@ -129,7 +137,7 @@ export function JdbcDriverProfiles({
try {
await call(commands.dbRemoveJdbcDriver(current.id));
onRemove(current.id);
setSelection(drivers.find((d) => d.id !== current.id)?.id ?? "");
setSelection(profiles.find((d) => d.id !== current.id)?.id ?? "");
} catch (e) {
setError(e instanceof Error ? e.message : String(e));
} finally {
@@ -144,7 +152,7 @@ export function JdbcDriverProfiles({
open
title={
draft
? drivers.some((d) => d.id === draft.id)
? profiles.some((d) => d.id === draft.id)
? "Edit JDBC Driver"
: "Add JDBC Driver"
: "JDBC Driver Profiles"
@@ -184,6 +192,16 @@ export function JdbcDriverProfiles({
disabled={busy}
onChange={(e) => set({ name: e.target.value })}
/>
<span className={styles.formLabel}>
<T>Data source type:</T>
</span>
<Select
aria-label="Data source type"
options={sourceVendor ? DRIVER_TYPES.filter((type) => type.value === sourceVendor) : DRIVER_TYPES}
value={draft.vendor ?? ""}
disabled={busy || !!sourceVendor}
onChange={(vendor) => set({ vendor: vendor || null })}
/>
<span className={styles.formLabel}>
<T>Driver and dependency JARs:</T>
</span>
@@ -252,14 +270,18 @@ export function JdbcDriverProfiles({
</span>
<Select
aria-label="JDBC driver profiles"
value={selection}
options={drivers.map((d) => ({ value: d.id, label: d.name, verbatim: true }))}
value={current?.id ?? ""}
options={profiles.map((d) => ({ value: d.id, label: d.name, verbatim: true }))}
placeholder="No JDBC driver profiles"
disabled={!profiles.length}
onChange={setSelection}
/>
<span />
<div className={styles.formRow}>
<Button icon="plus" onClick={() => edit(blankDriver())}>
<Button
icon="plus"
onClick={() => edit({ ...blankDriver(), ...(sourceVendor && { vendor: sourceVendor }) })}
>
<T>Add…</T>
</Button>
<Button disabled={!current} onClick={() => current && edit(current)}>
@@ -271,6 +293,10 @@ export function JdbcDriverProfiles({
</div>
{current && (
<dl className={styles.jdbcDetails}>
<dt>
<T>Data source type:</T>
</dt>
<dd>{tx(vendorById(current.vendor ?? "")?.label ?? "Custom JDBC only")}</dd>
<dt>
<T>Driver class:</T>
</dt>
@@ -328,6 +354,14 @@ export function JdbcDriverProfiles({
)
: tx`Delete driver profile ${name}? Data sources using it will need another driver profile.`}
</p>
{confirm === "trust" && changedType && (
<p className={styles.formFull}>
<T>
Sources that use this profile for its previous type will need a matching profile the next time they
connect, including sources in other projects.
</T>
</p>
)}
{confirm === "trust" && (
<ul className={styles.formFull}>
{draft?.jars.map((jar) => (
+506 -1
View File
@@ -1,8 +1,10 @@
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { DataSource, DbJdbcDriver } from "@/platform/ipc";
import type { DataSource, DbJdbcDriver, ProjectInfo } from "@/platform/ipc";
import { useProject } from "@/platform/project";
import { SourceDialog } from "./SourceDialog";
import { JdbcDriverProfiles } from "./JdbcDriverProfiles";
import { sourceIcon, sourceLabel } from "./model";
import { newMenu, nodeMenu } from "./treeMenu";
import { useDatabase } from "./store";
@@ -53,6 +55,7 @@ beforeEach(() => {
backend.saveSource.mockResolvedValue(undefined);
backend.pick.mockResolvedValue(driver.jars);
useDatabase.setState({ sources: [], dialog: null, loaded: true });
useProject.setState({ project: null });
});
describe("custom JDBC data sources", () => {
@@ -211,6 +214,8 @@ describe("custom JDBC data sources", () => {
expect(screen.getByRole("button", { name: "Test Connection" })).toBeEnabled();
select("Data source type", "ClickHouse");
expect(screen.getByLabelText("URL:")).toHaveValue(source.url!);
expect(screen.getByRole("button", { name: "Test Connection" })).toBeDisabled();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured built-in connection security." }));
fireEvent.click(screen.getByRole("button", { name: "Test Connection" }));
await waitFor(() =>
expect(backend.call).toHaveBeenCalledWith(["test", expect.objectContaining(source), null, null]),
@@ -234,7 +239,507 @@ describe("custom JDBC data sources", () => {
});
});
describe("JDBC drivers for named database types", () => {
it.each([
{ setting: "read-only", patch: { readOnly: true } },
{ setting: "startup script", patch: { options: { startupScript: "SET ROLE reader" } } },
{ setting: "default schema", patch: { options: { defaultSchema: "app" } } },
{ setting: "time zone", patch: { options: { timeZone: "UTC" } } },
{ setting: "manual transaction mode", patch: { options: { transaction: "manual" as const } } },
])("asks to review $setting before switching an unsaved native source", async ({ patch }) => {
const pg = { ...driver, vendor: "postgres", urlTemplate: "jdbc:example:local" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [pg] : "OK"));
render(<SourceDialog initial={null} preset={{ driver: "postgres", ...patch }} />);
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", pg.name);
const test = screen.getByRole("button", { name: "Test Connection" });
expect(test).toBeDisabled();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured JDBC connection security." }));
fireEvent.click(test);
await screen.findByText("Succeeded: OK");
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({ driver: "jdbc", properties: [] }),
null,
null,
]);
});
it("assigns a matching type to a saved Custom JDBC source without changing its URL or properties", async () => {
const clickhouse = { ...driver, vendor: "clickhouse" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [clickhouse] : "OK"));
const url = "jdbc:clickhouse:https://example.invalid:8443/sample";
const properties = [{ name: "socket_timeout", value: "2000" }];
render(<SourceDialog initial={{ driver: "jdbc", jdbcDriver: driver.id, url, properties }} />);
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Data source type", "ClickHouse");
expect(screen.getByRole("button", { name: "Connection driver" })).toHaveTextContent(driver.name);
expect(screen.getByLabelText("URL:")).toHaveValue(url);
fireEvent.click(screen.getByRole("button", { name: "OK" }));
await waitFor(() =>
expect(backend.saveSource).toHaveBeenCalledWith(
expect.objectContaining({ driver: "jdbc", vendor: "clickhouse", jdbcDriver: driver.id, url, properties }),
undefined,
undefined,
),
);
});
it("keeps the native Snowflake passphrase out of the JDBC draft", async () => {
const snowflake = { ...driver, vendor: "snowflake", urlTemplate: "jdbc:snowflake://example.invalid" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [snowflake] : "OK"));
render(
<SourceDialog
initial={{
driver: "snowflake",
host: "example.invalid",
user: "reader",
snowflake: { auth: "keyPair", privateKeyFile: "/fixture/key.pem" },
savePassword: true,
}}
/>,
);
fireEvent.change(screen.getByLabelText("Passphrase:"), { target: { value: "fixture-passphrase" } });
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", snowflake.name);
expect(screen.getByLabelText("Password:")).toHaveValue("");
expect(screen.getByRole("checkbox", { name: "Save password" })).not.toBeChecked();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured JDBC connection security." }));
fireEvent.click(screen.getByRole("button", { name: "Test Connection" }));
await screen.findByText("Succeeded: OK");
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({
driver: "jdbc",
savePassword: false,
snowflake: expect.objectContaining({ auth: "keyPair" }),
}),
null,
null,
]);
select("Connection driver", "Built-in");
expect(screen.getByLabelText("Passphrase:")).toHaveValue("fixture-passphrase");
expect(screen.getByRole("checkbox", { name: "Save password" })).toBeChecked();
select("Snowflake authentication", "Password");
expect(screen.getByLabelText("Password:")).toHaveValue("");
});
it("clears the typed Snowflake secret when a URL selects a different authentication method", async () => {
const snowflake = { ...driver, vendor: "snowflake", urlTemplate: "jdbc:snowflake://example.invalid" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [snowflake] : "OK"));
render(
<SourceDialog
initial={{
driver: "snowflake",
user: "reader",
urlOnly: true,
url: "jdbc:snowflake://example.invalid/?authenticator=oauth&password=fixture-url-token",
}}
/>,
);
fireEvent.change(screen.getByLabelText("Token:"), { target: { value: "fixture-token" } });
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", snowflake.name);
expect(screen.getByLabelText("Password:")).toHaveValue("");
expect(
screen.queryByText("If the connection used a password in the previous URL, enter it in the Password field."),
).toBeNull();
select("Connection driver", "Built-in");
expect(screen.getByLabelText("Token:")).toHaveValue("fixture-token");
fireEvent.change(screen.getByLabelText("URL:"), {
target: { value: "jdbc:snowflake://example.invalid/?authenticator=snowflake" },
});
expect(screen.getByLabelText("Password:")).toHaveValue("");
select("Connection driver", snowflake.name);
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured JDBC connection security." }));
fireEvent.click(screen.getByRole("button", { name: "Test Connection" }));
await screen.findByText("Succeeded: OK");
expect(backend.call).toHaveBeenCalledWith(["test", expect.objectContaining({ driver: "jdbc" }), "", null]);
});
it.each([
{ type: "clickhouse", url: "jdbc:clickhouse:https://new.example.invalid:8443/new", host: "new.example.invalid" },
{ type: "sqlServer", url: "jdbc:sqlserver://new.example.invalid;databaseName=new", host: "" },
])("reviews the actual $type endpoint before using the built-in driver", async ({ type, url, host }) => {
const profile = { ...driver, vendor: type };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [profile] : "OK"));
render(
<SourceDialog
initial={{
driver: "jdbc",
vendor: type,
host: "stale.example.invalid",
jdbcDriver: driver.id,
url,
options: { keepAliveSecs: 45 },
}}
/>,
);
await screen.findByRole("button", { name: "Go to Driver" });
select("Connection driver", "Built-in");
expect(screen.getByLabelText("Host:")).toHaveValue(host);
const test = screen.getByRole("button", { name: "Test Connection" });
expect(test).toBeDisabled();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured built-in connection security." }));
if (host) {
fireEvent.click(test);
await screen.findByText("Succeeded: OK");
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({
driver: "clickhouse",
host,
database: "new",
port: 8443,
ssl: "verifyFull",
options: expect.objectContaining({ keepAliveSecs: 45 }),
}),
null,
null,
]);
} else expect(test).toBeDisabled();
});
it("blocks an incompatible source and keeps the scoped manager empty", async () => {
render(
<SourceDialog initial={{ driver: "jdbc", vendor: "neon", jdbcDriver: driver.id, url: "jdbc:example:local" }} />,
);
expect(await screen.findByRole("alert")).toHaveTextContent(
"Select a matching profile or update its type in Custom JDBC.",
);
expect(screen.getByRole("button", { name: "Test Connection" })).toBeDisabled();
fireEvent.click(screen.getByRole("button", { name: "Manage Drivers…" }));
const profiles = within(screen.getByRole("dialog", { name: "JDBC Driver Profiles" }));
const picker = profiles.getByRole("button", { name: "JDBC driver profiles" });
expect(picker).toHaveTextContent("No JDBC driver profiles");
expect(picker).toBeDisabled();
expect(profiles.queryByRole("button", { name: "Use Driver" })).toBeNull();
});
it("uses a matching profile with a wire-compatible preset and reopens it with that type", async () => {
const pg = { ...driver, id: "pg", name: "PostgreSQL JDBC", vendor: "postgres" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [pg, { ...driver, vendor: "neon" }] : "OK"));
const { unmount } = render(
<SourceDialog
initial={{
id: "neon-example",
name: "Neon example",
driver: "postgres",
vendor: "neon",
host: "example.invalid",
ssl: "verifyFull",
sslCaFile: "/local/ca.pem",
urlOnly: true,
url: "postgresql://reader:url-fixture@example.invalid:5432/catalog?sslmode=verify-full",
savePassword: true,
}}
/>,
);
const driverButton = screen.getByRole("button", { name: "Connection driver" });
expect(driverButton).toHaveTextContent("Built-in");
const manage = screen.getByRole("button", { name: "Manage Drivers…" });
await waitFor(() => expect(manage).toBeEnabled());
fireEvent.click(driverButton);
const choices = within(screen.getByRole("listbox"));
expect(choices.getAllByRole("option")).toHaveLength(2);
fireEvent.click(choices.getByRole("option", { name: driver.name }));
expect(screen.getByRole("button", { name: "Data source type" })).toHaveTextContent("Neon");
expect(driverButton).toHaveTextContent(driver.name);
expect(screen.queryByRole("tab", { name: "SSH/SSL" })).toBeNull();
expect(screen.getByLabelText("User:")).toHaveValue("reader");
expect(
screen.getByText("If the connection used a password in the previous URL, enter it in the Password field."),
).toBeVisible();
const jdbcUrl = "jdbc:example://example.invalid/catalog?ssl=true";
fireEvent.change(screen.getByLabelText("URL:"), { target: { value: jdbcUrl } });
const save = screen.getByRole("button", { name: "OK" });
expect(save).toBeDisabled();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured JDBC connection security." }));
fireEvent.click(save);
await waitFor(() =>
expect(backend.saveSource).toHaveBeenCalledWith(
expect.objectContaining({
id: "neon-example",
driver: "jdbc",
vendor: "neon",
jdbcDriver: driver.id,
url: jdbcUrl,
user: "reader",
savePassword: true,
}),
undefined,
undefined,
),
);
const saved: DataSource = backend.saveSource.mock.calls[0]![0];
expect(sourceIcon(saved)).toBe("db-neon");
expect(sourceLabel(saved)).toBe("Neon example (Neon)");
unmount();
backend.call.mockImplementation(async ([op]) =>
op === "list"
? [
{ ...pg, vendor: "neon", urlTemplate: "jdbc:example://localhost/readonly" },
{ ...driver, vendor: "neon", urlTemplate: "jdbc:example://{host}/{database}?ssl=true" },
]
: "OK",
);
render(<SourceDialog initial={saved} />);
expect(screen.getByRole("button", { name: "Data source type" })).toHaveTextContent("Neon");
fireEvent.click(await screen.findByRole("button", { name: "Go to Driver" }));
const profiles = within(screen.getByRole("dialog", { name: "JDBC Driver Profiles" }));
expect(profiles.getByRole("button", { name: "JDBC driver profiles" })).toHaveTextContent(driver.name);
expect(profiles.getByText("dependency.jar")).toBeVisible();
fireEvent.click(profiles.getByText("Close", { exact: true }));
select("Connection driver", pg.name);
expect(screen.getByLabelText("URL:")).toHaveValue(jdbcUrl);
expect(screen.getByRole("button", { name: "Use URL template" })).toBeVisible();
expect(screen.getByRole("button", { name: "Test Connection" })).toBeDisabled();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured JDBC connection security." }));
expect(screen.getByRole("button", { name: "Test Connection" })).toBeEnabled();
fireEvent.click(screen.getByRole("button", { name: "Use URL template" }));
expect(screen.getByLabelText("URL:")).toHaveValue("jdbc:example://localhost/readonly");
expect(screen.getByRole("button", { name: "Test Connection" })).toBeDisabled();
});
const sqlite = { ...driver, name: "Xerial SQLite", vendor: "sqlite", urlTemplate: "jdbc:sqlite:{file}" };
it.each([
["/fixture/project", "fixtures/local.db", "/fixture/project/fixtures/local.db"],
["D:/fixture/project", "fixtures\\local.db", "D:/fixture/project/fixtures/local.db"],
["//fixture/project", "fixtures\\local.db", "//fixture/project/fixtures/local.db"],
])("uses a SQLite file relative to %s and restores its native path", async (root, file, absolute) => {
useProject.setState({ project: { root } as ProjectInfo });
backend.call.mockImplementation(async ([op]) => (op === "list" ? [sqlite] : "SQLite"));
render(<SourceDialog initial={null} preset={{ driver: "sqlite", file }} />);
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", sqlite.name);
const url = `jdbc:sqlite:${absolute}`;
expect(screen.getByLabelText("File:")).toHaveValue(absolute);
expect(screen.getByLabelText("URL:")).toHaveValue(url);
fireEvent.click(screen.getByRole("button", { name: "Test Connection" }));
await waitFor(() =>
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({ driver: "jdbc", vendor: "sqlite", url }),
null,
null,
]),
);
select("Connection driver", "Built-in");
expect(screen.getByLabelText("File:")).toHaveValue(file);
expect(screen.getByRole("button", { name: "Test Connection" })).toBeEnabled();
});
it("requires a fresh file choice for a Windows drive-relative path", async () => {
useProject.setState({ project: { root: "D:/fixture/project" } as ProjectInfo });
backend.call.mockImplementation(async ([op]) => (op === "list" ? [sqlite] : "SQLite"));
render(<SourceDialog initial={null} preset={{ driver: "sqlite", file: "D:local.db" }} />);
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", sqlite.name);
expect(screen.getByLabelText("File:")).toHaveValue("");
expect(screen.getByRole("button", { name: "Test Connection" })).toBeDisabled();
});
it("uses the file from the saved SQLite JDBC URL rather than stale template fields", async () => {
backend.call.mockImplementation(async ([op]) => (op === "list" ? [sqlite] : "SQLite"));
render(
<SourceDialog
initial={{
driver: "jdbc",
vendor: "sqlite",
jdbcDriver: sqlite.id,
url: "jdbc:sqlite:/fixture/new.db",
file: "/fixture/stale.db",
options: { keepAliveSecs: 45 },
}}
/>,
);
await screen.findByRole("button", { name: "Go to Driver" });
select("Connection driver", "Built-in");
expect(screen.getByLabelText("File:")).toHaveValue("/fixture/new.db");
const test = screen.getByRole("button", { name: "Test Connection" });
expect(test).toBeDisabled();
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured built-in connection security." }));
fireEvent.click(test);
await screen.findByText("Succeeded: SQLite");
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({ driver: "sqlite", options: expect.objectContaining({ keepAliveSecs: null }) }),
null,
null,
]);
});
it("clears keep-alive when switching from a native network source to built-in SQLite", async () => {
render(
<SourceDialog
initial={{
driver: "postgres",
options: { keepAliveSecs: 30, autoDisconnectSecs: 90 },
}}
/>,
);
select("Data source type", "SQLite");
fireEvent.change(screen.getByLabelText("File:"), { target: { value: "/fixture/local.db" } });
fireEvent.click(screen.getByRole("button", { name: "Test Connection" }));
await screen.findByText("Succeeded: Example database");
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({
driver: "sqlite",
options: expect.objectContaining({ keepAliveSecs: null, autoDisconnectSecs: 90 }),
}),
null,
null,
]);
});
it("leaves a legacy hidden SQLite keep-alive disabled when switching to JDBC", async () => {
backend.call.mockImplementation(async ([op]) => (op === "list" ? [sqlite] : "SQLite"));
render(
<SourceDialog
initial={{
driver: "sqlite",
file: "/fixture/local.db",
options: { keepAliveSecs: 30, autoDisconnectSecs: 90 },
}}
/>,
);
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", sqlite.name);
fireEvent.click(screen.getByRole("checkbox", { name: "I have configured JDBC connection security." }));
fireEvent.click(screen.getByRole("button", { name: "Test Connection" }));
await screen.findByText("Succeeded: SQLite");
expect(backend.call).toHaveBeenCalledWith([
"test",
expect.objectContaining({
driver: "jdbc",
options: expect.objectContaining({ keepAliveSecs: null, autoDisconnectSecs: 90 }),
}),
null,
null,
]);
});
it("keeps shared source options and restores the native draft's password", async () => {
const pg = { ...driver, name: "PostgreSQL JDBC", vendor: "postgres", urlTemplate: "jdbc:example:local" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [pg] : "OK"));
render(
<SourceDialog
initial={{
driver: "postgres",
user: "native",
savePassword: true,
options: { keepAliveSecs: 30, autoDisconnectSecs: 90 },
}}
/>,
);
fireEvent.change(screen.getByLabelText("Password:"), { target: { value: "native-fixture" } });
await waitFor(() => expect(screen.getByRole("button", { name: "Manage Drivers…" })).toBeEnabled());
select("Connection driver", pg.name);
expect(screen.getByRole("button", { name: "Test Connection" })).toBeDisabled();
fireEvent.change(screen.getByLabelText("User:"), { target: { value: "jdbc" } });
fireEvent.change(screen.getByLabelText("Password:"), { target: { value: "jdbc-fixture" } });
fireEvent.click(screen.getByRole("checkbox", { name: "Save password" }));
fireEvent.click(screen.getByRole("tab", { name: "Options" }));
const keepAlive = screen.getByLabelText("Run keep-alive query each (seconds)");
expect(keepAlive).toBeEnabled();
expect(keepAlive).toHaveValue("30");
fireEvent.change(keepAlive, { target: { value: "45" } });
expect(screen.getByLabelText("Auto-disconnect after (seconds)")).toHaveValue("90");
fireEvent.change(screen.getByLabelText("Auto-disconnect after (seconds)"), { target: { value: "60" } });
fireEvent.click(screen.getByRole("checkbox", { name: "Read-only" }));
fireEvent.click(screen.getByRole("tab", { name: "General" }));
select("Connection driver", "Built-in");
expect(screen.getByLabelText("User:")).toHaveValue("native");
expect(screen.getByLabelText("Password:")).toHaveValue("native-fixture");
expect(screen.getByRole("checkbox", { name: "Save password" })).not.toBeChecked();
fireEvent.click(screen.getByRole("tab", { name: "Options" }));
expect(screen.getByRole("checkbox", { name: "Read-only" })).toBeChecked();
expect(screen.getByLabelText("Run keep-alive query each (seconds)")).toHaveValue("45");
expect(screen.getByLabelText("Auto-disconnect after (seconds)")).toHaveValue("60");
});
});
describe("local JDBC driver profiles", () => {
it("scopes the picker, editing and deletion to the source's type", async () => {
const clickhouse = { ...driver, id: "ch", name: "ClickHouse JDBC", vendor: "clickhouse" };
const sqlite = { ...driver, id: "sqlite", name: "SQLite JDBC", vendor: "sqlite" };
const pg = { ...driver, id: "pg", name: "PostgreSQL JDBC", vendor: "postgres" };
backend.call.mockImplementation(async ([op]) => (op === "list" ? [sqlite, pg, driver, clickhouse] : "OK"));
render(<SourceDialog initial={null} preset={{ driver: "clickhouse" }} />);
const manage = screen.getByRole("button", { name: "Manage Drivers…" });
await waitFor(() => expect(manage).toBeEnabled());
fireEvent.click(manage);
const profiles = within(screen.getByRole("dialog", { name: "JDBC Driver Profiles" }));
const picker = profiles.getByRole("button", { name: "JDBC driver profiles" });
expect(picker).toHaveTextContent(clickhouse.name);
fireEvent.click(picker);
const choices = within(screen.getByRole("listbox"));
expect(choices.getAllByRole("option")).toHaveLength(1);
fireEvent.click(choices.getByRole("option", { name: clickhouse.name }));
fireEvent.click(profiles.getByRole("button", { name: "Edit…" }));
const editor = within(screen.getByRole("dialog", { name: "Edit JDBC Driver" }));
const type = editor.getByRole("button", { name: "Data source type" });
expect(type).toHaveTextContent("ClickHouse");
expect(type).toBeDisabled();
fireEvent.click(editor.getByRole("button", { name: "Cancel" }));
fireEvent.click(profiles.getByRole("button", { name: "Delete…" }));
fireEvent.click(screen.getByRole("button", { name: "Delete" }));
await waitFor(() => {
const emptyPicker = profiles.getByRole("button", { name: "JDBC driver profiles" });
expect(emptyPicker).toHaveTextContent("No JDBC driver profiles");
expect(emptyPicker).toBeDisabled();
});
expect(backend.call).toHaveBeenCalledWith(["remove", clickhouse.id]);
expect(profiles.getByRole("button", { name: "Edit…" })).toBeDisabled();
expect(profiles.getByRole("button", { name: "Delete…" })).toBeDisabled();
fireEvent.click(profiles.getByRole("button", { name: "Add…" }));
const addType = within(screen.getByRole("dialog", { name: "Add JDBC Driver" })).getByRole("button", {
name: "Data source type",
});
expect(addType).toHaveTextContent("ClickHouse");
expect(addType).toBeDisabled();
});
it("lets the unscoped manager associate an existing legacy profile", async () => {
render(
<JdbcDriverProfiles
drivers={[driver]}
selected={driver.id}
onSave={vi.fn()}
onRemove={vi.fn()}
onClose={vi.fn()}
/>,
);
fireEvent.click(screen.getByRole("button", { name: "Edit…" }));
select("Data source type", "Neon");
fireEvent.click(screen.getByRole("button", { name: "Save" }));
fireEvent.click(screen.getByRole("button", { name: "Trust and Save" }));
await waitFor(() => expect(backend.call).toHaveBeenCalledWith(["save", { ...driver, vendor: "neon" }]));
});
it("warns before reassigning a profile previously associated with a named type", async () => {
render(
<JdbcDriverProfiles
drivers={[{ ...driver, vendor: "postgres" }]}
selected={driver.id}
onSave={vi.fn()}
onRemove={vi.fn()}
onClose={vi.fn()}
/>,
);
fireEvent.click(screen.getByRole("button", { name: "Edit…" }));
select("Data source type", "Neon");
fireEvent.click(screen.getByRole("button", { name: "Save" }));
expect(await screen.findByRole("dialog", { name: "Trust JDBC Driver?" })).toHaveTextContent(
"including sources in other projects.",
);
expect(backend.call.mock.calls.some(([[op]]) => op === "save")).toBe(false);
});
it("validates profiles, selects dependency JARs and requires trust before saving", async () => {
const saved = vi.fn();
render(<JdbcDriverProfiles drivers={[]} selected="" onSave={saved} onRemove={vi.fn()} onClose={vi.fn()} />);
+10 -3
View File
@@ -12,12 +12,19 @@ vi.mock("@/platform/ipc", async (importOriginal) => {
return {
...real,
call: ipc.call,
commands: { ...real.commands, dbTest: request("dbTest"), dbTestTunnel: request("dbTestTunnel") },
commands: {
...real.commands,
dbJdbcDrivers: request("dbJdbcDrivers"),
dbTest: request("dbTest"),
dbTestTunnel: request("dbTestTunnel"),
},
};
});
const savePassword = () => screen.getByRole("checkbox", { name: "Save password" }) as HTMLInputElement;
ipc.call.mockResolvedValue([]);
describe("new data source", () => {
it("does not save the database password unless asked to", () => {
render(<SourceDialog initial={null} />);
@@ -59,7 +66,7 @@ describe("new data source", () => {
describe("Test SSH Tunnel", () => {
it("tests the tunnel typed in the SSH/SSL tab, without the database login", async () => {
ipc.call.mockResolvedValue("dev@bastion:22 reaches 127.0.0.1:5432");
ipc.call.mockImplementation(async ([op]) => (op === "dbTestTunnel" ? "dev@bastion:22 reaches 127.0.0.1:5432" : []));
render(<SourceDialog initial={null} preset={{ driver: "postgres", host: "127.0.0.1" }} />);
fireEvent.click(screen.getByRole("tab", { name: "SSH/SSL" }));
const button = () => screen.getByRole("button", { name: "Test SSH Tunnel" }) as HTMLButtonElement;
@@ -71,7 +78,7 @@ describe("Test SSH Tunnel", () => {
await waitFor(() =>
expect(screen.getByRole("status").textContent).toBe("SSH tunnel works: dev@bastion:22 reaches 127.0.0.1:5432"),
);
expect(ipc.call.mock.calls[0]?.[0]?.[0]).toBe("dbTestTunnel");
expect(ipc.call).toHaveBeenCalledWith(["dbTestTunnel", expect.anything(), null]);
ipc.call.mockClear();
});
});
+308 -117
View File
@@ -22,6 +22,7 @@ import {
} from "@/platform/ipc";
import { executeAction } from "@/platform/actions";
import { tx, useTx, useTxTemplate } from "@/platform/i18n";
import { useProject } from "@/platform/project";
import { sshLabel as configLabel } from "@/platform/remoteSettings";
import { useWorkflowSettings } from "@/platform/workflowSettings";
import { Button, Checkbox, Dialog, IconButton, Input, Select, Tabs, T, type SelectOption } from "@/ui";
@@ -181,6 +182,54 @@ const parseSecs = (v: string) => {
return Number.isFinite(n) && n > 0 ? n : null;
};
const windowsAbsolutePath = /^(?:[A-Za-z]:[/\\]|[/\\]{2})/;
const jdbcUrlPlaceholder = /<[^>]+>|\{(?:host|port|database|file)\}/;
function absoluteDatabaseFile(path: string, root: string | undefined): boolean {
return root && windowsAbsolutePath.test(root)
? windowsAbsolutePath.test(path)
: path.startsWith("/") || (!root && windowsAbsolutePath.test(path));
}
function sqliteJdbcFile(file: string | null | undefined, root: string | undefined): string | null {
if (!file) return null;
const windows = !!root && windowsAbsolutePath.test(root);
const path = windows ? file.replace(/\\/g, "/") : file;
if (absoluteDatabaseFile(path, root)) return path;
// Windows drive-relative and current-drive paths depend on the process's working directory.
if (!root || (windows && /^(?:[A-Za-z]:|\/)/.test(path))) return null;
const directory = windows ? root.replace(/\\/g, "/") : root;
return `${directory.replace(/\/+$/, "")}/${path}`;
}
function builtInTarget(s: DataSource, driver: DataSource["driver"], root: string | undefined): Partial<DataSource> {
const url = s.url ?? "";
if (driver === "sqlite") {
const path = /^jdbc:sqlite3?:(.+)$/i.exec(url)?.[1] ?? "";
const file = windowsAbsolutePath.test(root ?? "") ? path.replace(/^\/([A-Za-z]:[/\\])/, "$1") : path;
return {
file: !/[?#]/.test(file) && !jdbcUrlPlaceholder.test(file) && absoluteDatabaseFile(file, root) ? file : null,
};
}
// The native form has one host. Multi-host and driver-specific descriptors need a manual target.
const target = url.replace(/^jdbc:clickhouse:(?=https?:\/\/)/i, "");
const parsed =
jdbcUrlPlaceholder.test(target) || target.includes("#") || /[;,\s]/.test(target.split("?", 1)[0] ?? "")
? null
: parseSourceUrl(target)?.source;
if (parsed?.driver !== driver || !parsed?.host) return { host: "", port: null, database: "", ssl: "verifyFull" };
return {
host: parsed.host,
port: parsed.port,
database: parsed.database,
user: parsed.user || s.user,
ssl: parsed.ssl && parsed.ssl !== "prefer" ? parsed.ssl : "verifyFull",
sslCaFile: parsed.sslCaFile ?? "",
sslCertFile: parsed.sslCertFile ?? "",
sslKeyFile: parsed.sslKeyFile ?? "",
};
}
function blank(): DataSource {
return {
id: newSourceId(),
@@ -396,21 +445,51 @@ export function SourceDialog({
// The URL being typed in default mode (null: show the fields' URL).
const [urlDraft, setUrlDraft] = useState<string | null>(null);
const [showJdbcProfiles, setShowJdbcProfiles] = useState(false);
const [nativeSource, setNativeSource] = useState<DataSource | null>(null);
const [jdbcSecurityConfirmed, setJdbcSecurityConfirmed] = useState(false);
const [nativeDraft, setNativeDraft] = useState<{
source: DataSource;
password: string | undefined;
endpoint: Pick<DataSource, "host" | "port" | "database" | "user" | "file">;
} | null>(null);
const nativeSource = nativeDraft?.source;
const [restoredNativeTarget, setRestoredNativeTarget] = useState(false);
const [connectionSecurityConfirmed, setConnectionSecurityConfirmed] = useState(false);
const jdbc = s.driver === "jdbc";
const jdbcProfiles = useJdbcDrivers(jdbc);
const jdbcProfile = jdbcProfiles.drivers?.find((d) => d.id === s.jdbcDriver);
const vendor = vendorOf(s);
const genericJdbc = vendor.id === "jdbc";
const savedJdbcWithPreset = initial?.driver === "jdbc" && (!genericJdbc || vendorOf(initial).driver !== "jdbc");
const jdbcProfiles = useJdbcDrivers();
const availableProfiles = jdbcProfiles.drivers?.filter((d) => genericJdbc || d.vendor === vendor.id);
const jdbcProfile = availableProfiles?.find((d) => d.id === s.jdbcDriver);
const installedJdbcProfile = jdbcProfiles.drivers?.find((d) => d.id === s.jdbcDriver);
const projectRoot = useProject((st) => st.project?.root);
const nativeUrl = nativeSource?.urlOnly ? parseSourceUrl(nativeSource.url ?? "") : null;
const nativeOptions = nativeSource?.options;
const reviewSessionSettings =
nativeOptions?.startupScript ||
nativeOptions?.defaultSchema ||
nativeOptions?.timeZone ||
nativeOptions?.transaction === "manual";
const newJdbcPassword = jdbc && nativeSource?.driver === "snowflake" && s.snowflake?.auth !== "password";
const reviewJdbcSecurity =
nativeSource &&
(nativeSource.driver === "clickhouse" ||
nativeSource.ssh?.enabled ||
nativeSource.urlOnly ||
["require", "verifyCa", "verifyFull"].includes(nativeSource.ssl ?? "") ||
nativeSource.sslCaFile ||
nativeSource.sslCertFile ||
nativeSource.sslKeyFile ||
(nativeSource.properties?.length ?? 0) > 0);
jdbc &&
((savedJdbcWithPreset &&
(initial.jdbcDriver !== s.jdbcDriver ||
nativeSource ||
(s.url && s.url === jdbcProfile?.urlTemplate && s.url !== initial.url))) ||
(nativeSource &&
(!!initial ||
nativeSource.driver === "clickhouse" ||
nativeSource.driver === "snowflake" ||
nativeSource.ssh?.enabled ||
nativeSource.urlOnly ||
["require", "verifyCa", "verifyFull"].includes(nativeSource.ssl ?? "") ||
nativeSource.sslCaFile ||
nativeSource.sslCertFile ||
nativeSource.sslKeyFile ||
nativeSource.readOnly ||
reviewSessionSettings ||
(nativeSource.properties?.length ?? 0) > 0)));
const reviewBuiltinSecurity = !jdbc && (initial?.driver === "jdbc" || restoredNativeTarget);
const loadedDbs = useDatabase((st) => (initial?.id ? st.databases[initial.id] : undefined));
const loadedSchemas = useDatabase((st) => (initial?.id ? st.schemas[initial.id] : undefined));
@@ -423,6 +502,10 @@ export function SourceDialog({
const sshUsed: DbSsh = effectiveSsh(ssh, sshConfigs) ?? ssh;
const setSsh = (patch: Partial<DbSsh>) => setS((x) => ({ ...x, ssh: { ...blankSsh(), ...x.ssh, ...patch } }));
const options: DbOptions = { ...blankOptions(), ...s.options };
const connectionTimers = (targetDriver: DataSource["driver"]) => ({
keepAliveSecs: s.driver === "sqlite" || targetDriver === "sqlite" ? null : options.keepAliveSecs,
autoDisconnectSecs: options.autoDisconnectSecs,
});
const setOptions = (patch: Partial<DbOptions>) =>
setS((x) => ({ ...x, options: { ...blankOptions(), ...x.options, ...patch } }));
const intro: DbIntrospection = { ...blankIntrospection(), ...s.introspection };
@@ -432,7 +515,6 @@ export function SourceDialog({
const setProperty = (i: number, patch: Partial<DbProperty>) =>
set({ properties: properties.map((p, j) => (j === i ? { ...p, ...patch } : p)) });
const vendor = vendorOf(s);
const sqlite = s.driver === "sqlite";
const postgres = s.driver === "postgres";
/** Drivers that can list every database on the host (tree level + Schemas tab). */
@@ -441,19 +523,22 @@ export function SourceDialog({
const oracle = s.driver === "oracle";
const snowflake = s.driver === "snowflake";
const sf: DbSnowflake = { ...blankSnowflake(), ...s.snowflake };
const setSnowflake = (patch: Partial<DbSnowflake>) =>
setS((x) => ({ ...x, snowflake: { ...blankSnowflake(), ...x.snowflake, ...patch } }));
const browserSignIn = snowflake && sf.auth === "browser";
const urlOnly = !sqlite && !jdbc && !!s.urlOnly;
const parsedUrl = urlOnly ? parseSourceUrl(s.url ?? "") : null;
const snowflakeAuth = parsedUrl?.source.snowflake?.auth ?? sf.auth;
const setSnowflake = (patch: Partial<DbSnowflake>) => {
if (patch.auth && patch.auth !== snowflakeAuth) setPassword("");
setS((x) => ({ ...x, snowflake: { ...blankSnowflake(), ...x.snowflake, ...patch } }));
};
const browserSignIn = snowflake && snowflakeAuth === "browser";
const urlValid = !!parsedUrl && parsedUrl.source.driver === s.driver;
const host = urlOnly ? (parsedUrl?.source.host ?? "") : (s.host ?? "");
const database = urlOnly ? (parsedUrl?.source.database ?? "") : (s.database ?? "");
const name =
s.name?.trim() ||
(jdbc
(genericJdbc
? (jdbcProfile?.name ?? tx("Custom JDBC"))
: sqlite
: vendor.driver === "sqlite"
? fileSourceName(s.file ?? "")
: `${database || s.user || "db"}@${host || "localhost"}`);
// Snowflake is reached over HTTPS, where a tunnel to another host name cannot pass certificate checks.
@@ -466,20 +551,55 @@ export function SourceDialog({
);
const fromTemplate = !!templateFields.length && (s.url === template || s.url === renderedUrl);
const jdbcUrl = fromTemplate ? renderedUrl : (s.url ?? "");
const chooseProfile = (profile?: DbJdbcDriver) => {
const wasDefault = !s.url || fromTemplate || s.url === jdbcProfile?.urlTemplate;
set({ jdbcDriver: profile?.id ?? "", url: wasDefault ? (profile?.urlTemplate ?? "") : s.url });
const chooseProfile = (profile?: DbJdbcDriver, type = vendor) => {
setTest(null);
setConnectionSecurityConfirmed(false);
if (jdbc) {
const wasDefault = !s.url || (!savedJdbcWithPreset && (fromTemplate || s.url === jdbcProfile?.urlTemplate));
set({ jdbcDriver: profile?.id ?? "", url: wasDefault ? (profile?.urlTemplate ?? "") : s.url });
return;
}
const parsed = s.urlOnly ? parseSourceUrl(s.url ?? "")?.source : undefined;
const file = parsed?.file ?? s.file;
const secure = ["require", "verifyCa", "verifyFull"].includes(parsed?.ssl ?? s.ssl ?? "");
const endpoint = {
host: parsed?.host ?? s.host,
port: (parsed ? parsed.port : s.port) ?? (clickhouse && secure ? 8443 : vendor.port),
database: parsed?.database ?? s.database,
user: parsed?.user || s.user,
file: sqlite ? sqliteJdbcFile(file, projectRoot) : file,
};
setNativeDraft({ source: s, password, endpoint });
const snowflakeOptions = { ...sf, ...parsed?.snowflake };
const needsJdbcPassword = snowflake && snowflakeOptions.auth !== "password";
if (needsJdbcPassword) setPassword(undefined);
set({
...endpoint,
driver: "jdbc",
vendor: type.driver === "jdbc" ? "" : type.id,
...(snowflake ? { snowflake: snowflakeOptions } : {}),
...(needsJdbcPassword ? { savePassword: false } : {}),
urlOnly: true,
url: profile?.urlTemplate ?? "",
jdbcDriver: profile?.id ?? "",
properties: [],
options: { ...blankOptions(), ...connectionTimers("jdbc") },
ssh: null,
ssl: "disable",
sslCaFile: "",
sslCertFile: "",
sslKeyFile: "",
});
};
const jdbcUrlValid =
/^jdbc:[^\s:]+:[^\r\n]*$/.test(jdbcUrl) && !/<[^>]+>|\{(?:host|port|database|file)\}/.test(jdbcUrl);
const jdbcUrlValid = /^jdbc:[^\s:]+:[^\r\n]*$/.test(jdbcUrl) && !jdbcUrlPlaceholder.test(jdbcUrl);
const valid = jdbc
? !!jdbcProfile && jdbcUrlValid && (!reviewJdbcSecurity || jdbcSecurityConfirmed)
: sqlite
? !!s.file?.trim()
: (urlOnly ? urlValid : !!s.host?.trim()) &&
(!sshOn || sshTunnelReady(ssh, sshConfigs)) &&
(!snowflake || (!!s.user?.trim() && (sf.auth !== "keyPair" || !!sf.privateKeyFile?.trim())));
? !!jdbcProfile && jdbcUrlValid && (!reviewJdbcSecurity || connectionSecurityConfirmed)
: (!reviewBuiltinSecurity || connectionSecurityConfirmed) &&
(sqlite
? !!s.file?.trim()
: (urlOnly ? urlValid : !!s.host?.trim()) &&
(!sshOn || sshTunnelReady(ssh, sshConfigs)) &&
(!snowflake || (!!s.user?.trim() && (sf.auth !== "keyPair" || !!sf.privateKeyFile?.trim()))));
const sslOn = (s.ssl ?? "prefer") !== "disable";
/** What is saved / tested: a preset's port when the field was left empty. */
@@ -498,33 +618,21 @@ export function SourceDialog({
: {}),
});
const setType = (id: string) => {
const setType = (id: string, builtIn = false) => {
const v = vendorById(id);
if (!v) return;
if (!v || (v.id === vendor.id && (!jdbc || !builtIn))) return;
setTest(null);
setUrlDraft(null);
if (v.driver === "jdbc" && !jdbc) {
setNativeSource(s);
setJdbcSecurityConfirmed(false);
setS({
...s,
driver: "jdbc",
vendor: "",
port: s.port ?? vendor.port,
urlOnly: true,
url: "",
jdbcDriver: "",
properties: [],
options: blankOptions(),
ssh: null,
ssl: "disable",
sslCaFile: "",
sslCertFile: "",
sslKeyFile: "",
});
setConnectionSecurityConfirmed(false);
if (v.driver === "jdbc") {
if (jdbc) set({ vendor: "" });
else chooseProfile(undefined, v);
return;
}
if (jdbc && genericJdbc && installedJdbcProfile?.vendor === v.id) {
set({ vendor: v.id });
return;
}
if (v.driver === s.driver && v.id === vendor.id) return;
const previous =
jdbc && nativeSource
? {
@@ -533,9 +641,23 @@ export function SourceDialog({
color: s.color,
comment: s.comment,
global: s.global,
savePassword: newJdbcPassword ? nativeSource.savePassword : s.savePassword,
readOnly: s.readOnly,
introspection: intro,
options: { ...blankOptions(), ...nativeSource.options, ...connectionTimers(v.driver) },
}
: s;
setNativeSource(null);
if (nativeDraft) {
setPassword(nativeDraft.password);
const changed = (["host", "port", "database", "user", "file"] as const).some(
(field) => s[field] !== nativeDraft.endpoint[field],
);
setRestoredNativeTarget(changed || (!!s.url && !fromTemplate && s.url !== template));
} else {
setRestoredNativeTarget(false);
if (jdbc && v.driver === "snowflake" && sf.auth !== "password") setPassword(undefined);
}
setNativeDraft(null);
if (jdbc && nativeSource && vendorOf(nativeSource).id === v.id) {
setS(previous);
return;
@@ -550,6 +672,7 @@ export function SourceDialog({
vendor: v.id === v.driver ? "" : v.id,
port,
ssl: v.ssl ?? (v.driver === "clickhouse" ? "disable" : x.ssl),
...(v.driver === "sqlite" && x.driver !== "jdbc" ? { options: { ...x.options, keepAliveSecs: null } } : {}),
...(v.driver === "snowflake"
? { host: x.host === "localhost" ? "" : x.host, snowflake: { ...blankSnowflake(), ...x.snowflake } }
: {}),
@@ -560,6 +683,17 @@ export function SourceDialog({
options: { ...blankOptions(), ...x.options, transaction: "auto" as const },
}
: {}),
...(x.driver === "jdbc"
? {
jdbcDriver: "",
urlOnly: false,
url: "",
properties: [],
options: { ...blankOptions(), ...connectionTimers(v.driver) },
ssh: null,
...builtInTarget({ ...x, url: jdbcUrl }, v.driver, projectRoot),
}
: {}),
};
});
};
@@ -586,7 +720,14 @@ export function SourceDialog({
if (p.password) setPassword(p.password);
};
const setUrlOnly = (on: boolean) => set(on && !s.url?.trim() ? { urlOnly: on, url: sourceUrl(s) } : { urlOnly: on });
const setConnectionUrl = (url: string, on: boolean) => {
if (snowflake) {
const auth = (on ? parseSourceUrl(url)?.source.snowflake?.auth : undefined) ?? sf.auth;
if (auth !== snowflakeAuth) setPassword("");
}
set({ url, urlOnly: on });
};
const setUrlOnly = (on: boolean) => setConnectionUrl(on && !s.url?.trim() ? sourceUrl(s) : (s.url ?? ""), on);
/** Test Connection, or with `tunnel` the SSH/SSL tab's Test SSH Tunnel (no database login). */
const runTest = async (tunnel = false) => {
@@ -656,9 +797,59 @@ export function SourceDialog({
const general = (
<>
<span className={styles.formLabel}>
<T>Driver:</T>
<T>Data source type:</T>
</span>
<Select aria-label="Data source type" value={vendor.id} options={TYPES} onChange={setType} />
<Select aria-label="Data source type" value={vendor.id} options={TYPES} onChange={(id) => setType(id)} />
<span className={styles.formLabel}>{tx(genericJdbc ? "JDBC driver profile:" : "Driver:")}</span>
<div className={styles.formRow}>
<Select
className={styles.fill}
aria-label={genericJdbc ? "JDBC driver profile" : "Connection driver"}
value={jdbc ? (s.jdbcDriver ?? "") : ""}
disabled={genericJdbc && !jdbcProfiles.drivers}
onChange={(id) => {
if (!id && !genericJdbc) setType(vendor.id, true);
else chooseProfile(availableProfiles?.find((d) => d.id === id));
}}
options={[
{ value: "", label: genericJdbc ? "Choose a JDBC driver profile" : "Built-in" },
...(availableProfiles ?? []).map((d) => ({ value: d.id, label: d.name, verbatim: true })),
...(jdbc && s.jdbcDriver && !jdbcProfile
? [
{
value: s.jdbcDriver,
label: installedJdbcProfile?.name ?? tx`${s.jdbcDriver} (missing)`,
verbatim: true,
disabled: true,
},
]
: []),
]}
/>
<Button disabled={!jdbcProfiles.drivers} onClick={() => setShowJdbcProfiles(true)}>
{tx(jdbc && jdbcProfile && !genericJdbc ? "Go to Driver" : "Manage Drivers…")}
</Button>
</div>
{jdbcProfiles.error ? (
<div className={styles.formFull} role="alert">
{jdbcProfiles.error}{" "}
<Button onClick={jdbcProfiles.retry}>
<T>Retry</T>
</Button>
</div>
) : !jdbcProfiles.drivers && jdbc ? (
<span className={styles.formFull} role="status">
<T>Loading JDBC driver profiles…</T>
</span>
) : jdbc && s.jdbcDriver && !jdbcProfile && jdbcProfiles.drivers ? (
<span className={`${styles.formFull} ${styles.bad}`} role="alert">
{tx(
installedJdbcProfile
? "The JDBC driver profile is assigned to a different data source type. Select a matching profile or update its type in Custom JDBC."
: "The JDBC driver profile is missing. Select or add a profile before connecting.",
)}
</span>
) : null}
{sqlite ? (
<FileField
id="db-file"
@@ -672,28 +863,6 @@ export function SourceDialog({
<>
{jdbc ? (
<>
<span className={styles.formLabel}>
<T>JDBC driver profile:</T>
</span>
<div className={styles.formRow}>
<Select
className={styles.fill}
aria-label="JDBC driver profile"
value={s.jdbcDriver ?? ""}
disabled={!jdbcProfiles.drivers}
onChange={(id) => chooseProfile(jdbcProfiles.drivers?.find((d) => d.id === id))}
options={[
{ value: "", label: "Choose a JDBC driver profile" },
...(jdbcProfiles.drivers ?? []).map((d) => ({ value: d.id, label: d.name, verbatim: true })),
...(s.jdbcDriver && !jdbcProfile
? [{ value: s.jdbcDriver, label: tx`${s.jdbcDriver} (missing)` }]
: []),
]}
/>
<Button disabled={!jdbcProfiles.drivers} onClick={() => setShowJdbcProfiles(true)}>
<T>Manage Drivers…</T>
</Button>
</div>
{fromTemplate &&
templateFields.map((key) => (
<Fragment key={key}>
@@ -722,30 +891,20 @@ export function SourceDialog({
</div>
</Fragment>
))}
{!fromTemplate && templateFields.length > 0 && (
{!fromTemplate && template && s.url !== template && (
<>
<span />
<Button onClick={() => set({ url: template })}>
<Button
onClick={() => {
set({ url: template });
setTest(null);
setConnectionSecurityConfirmed(false);
}}
>
<T>Use URL template</T>
</Button>
</>
)}
{jdbcProfiles.error ? (
<div className={styles.formFull} role="alert">
{jdbcProfiles.error}{" "}
<Button onClick={jdbcProfiles.retry}>
<T>Retry</T>
</Button>
</div>
) : !jdbcProfiles.drivers ? (
<span className={styles.formFull} role="status">
<T>Loading JDBC driver profiles…</T>
</span>
) : s.jdbcDriver && !jdbcProfile ? (
<span className={`${styles.formFull} ${styles.bad}`} role="alert">
<T>The JDBC driver profile is missing. Select or add a profile before connecting.</T>
</span>
) : null}
</>
) : (
<>
@@ -836,7 +995,7 @@ export function SourceDialog({
</>
)}
<label className={styles.formLabel} htmlFor="db-password" hidden={browserSignIn}>
{tx(snowflake ? snowflakeSecretLabel(sf.auth) : "Password:")}
{tx(snowflake ? snowflakeSecretLabel(snowflakeAuth) : "Password:")}
</label>
<div className={styles.formRow} hidden={browserSignIn}>
<Input
@@ -845,7 +1004,7 @@ export function SourceDialog({
type="password"
value={password ?? ""}
placeholder={
initial && password === undefined
initial && password === undefined && !newJdbcPassword
? "<unchanged>"
: snowflake && sf.auth === "keyPair"
? "Only for an encrypted key"
@@ -917,7 +1076,7 @@ export function SourceDialog({
: urlDraft !== null && parseSourceUrl(urlDraft)?.source.driver !== s.driver
}
placeholder={jdbc ? jdbcProfile?.urlTemplate : sourceUrl(s)}
onChange={(e) => (jdbc || urlOnly ? set({ url: e.target.value }) : typeUrl(e.target.value))}
onChange={(e) => (jdbc || urlOnly ? setConnectionUrl(e.target.value, true) : typeUrl(e.target.value))}
onBlur={() => setUrlDraft(null)}
/>
<span />
@@ -934,23 +1093,53 @@ export function SourceDialog({
: "Editing the URL fills in the settings above.",
)}
</span>
{jdbc && reviewJdbcSecurity && (
<div className={styles.formWide}>
<span className={styles.formHint}>
<T>
Review the JDBC URL, TLS settings and connection properties. If your native connection used an SSH
tunnel, configure the equivalent route before connecting.
</T>
</span>
<Checkbox
checked={jdbcSecurityConfirmed}
onChange={setJdbcSecurityConfirmed}
label="I have configured JDBC connection security."
/>
</div>
)}
</>
)}
{(reviewJdbcSecurity || reviewBuiltinSecurity) && (
<div className={styles.formWide}>
<span className={styles.formHint}>
{jdbc
? tx(
"Review the JDBC URL, TLS settings and connection properties. If your native connection used an SSH tunnel, configure the equivalent route before connecting.",
)
: tx(
restoredNativeTarget
? "The built-in driver restores the previous target and credentials. Review them before connecting."
: "Review the built-in connection settings, credentials and TLS before connecting.",
)}
</span>
{jdbc && nativeSource?.readOnly && (
<span className={styles.formHint}>
<T>JDBC asks the driver for a read-only connection. Use a database account with read-only privileges.</T>
</span>
)}
{jdbc && reviewSessionSettings && (
<span className={styles.formHint}>
<T>
JDBC uses auto-commit. Review your startup script, default schema, and time zone, and configure
equivalent settings supported by your driver or database.
</T>
</span>
)}
{newJdbcPassword && (
<span className={styles.formHint}>
<T>This source uses a separate credential for JDBC. Enter a password if your driver requires one.</T>
</span>
)}
{jdbc && !newJdbcPassword && nativeUrl?.password && (
<span className={styles.formHint}>
<T>If the connection used a password in the previous URL, enter it in the Password field.</T>
</span>
)}
<Checkbox
checked={connectionSecurityConfirmed}
onChange={setConnectionSecurityConfirmed}
label={
jdbc ? "I have configured JDBC connection security." : "I have configured built-in connection security."
}
/>
</div>
)}
</>
);
@@ -1499,14 +1688,16 @@ export function SourceDialog({
)}
</div>
</div>
{jdbc && showJdbcProfiles && jdbcProfiles.drivers && (
{showJdbcProfiles && jdbcProfiles.drivers && (
<JdbcDriverProfiles
drivers={jdbcProfiles.drivers}
selected={s.jdbcDriver ?? ""}
selected={jdbc ? (jdbcProfile?.id ?? "") : ""}
sourceVendor={genericJdbc ? undefined : vendor.id}
onClose={() => setShowJdbcProfiles(false)}
onSave={(driver) => {
jdbcProfiles.setDrivers((drivers) => [...(drivers ?? []).filter((d) => d.id !== driver.id), driver]);
if (!s.jdbcDriver || s.jdbcDriver === driver.id) chooseProfile(driver);
if (jdbc && (genericJdbc || driver.vendor === vendor.id) && (!s.jdbcDriver || s.jdbcDriver === driver.id))
chooseProfile(driver);
}}
onUse={(driver) => {
chooseProfile(driver);
+4 -3
View File
@@ -5,7 +5,7 @@
import type { DataSource, DbDriver, DbSnowflake, DbSslMode } from "@/platform/ipc";
export interface DbVendor {
/** Stored in `DataSource.vendor`; a driver's own entry has the driver's id. */
/** Stored in `DataSource.vendor` when the transport differs from the preset. */
id: string;
label: string;
driver: DbDriver;
@@ -112,7 +112,8 @@ const BY_ID = new Map(VENDORS.map((v) => [v.id, v]));
/** The type of a data source: its preset, else its driver's own entry. */
export function vendorOf(s: Pick<DataSource, "vendor" | "driver">): DbVendor {
const v = s.vendor ? BY_ID.get(s.vendor) : undefined;
return v && v.driver === (s.driver ?? "sqlite") ? v : BY_ID.get(s.driver ?? "sqlite")!;
const driver = s.driver ?? "sqlite";
return v && (v.driver === driver || driver === "jdbc") ? v : BY_ID.get(driver)!;
}
export const vendorById = (id: string): DbVendor | undefined => BY_ID.get(id);
@@ -190,7 +191,7 @@ const bracketed = (host: string) => (host.includes(":") && !host.startsWith("[")
/** The JDBC URL of a data source's fields (the General tab's URL preview). */
export function sourceUrl(s: DataSource): string {
const v = vendorOf(s);
if (v.driver === "jdbc") return s.url ?? "";
if (s.driver === "jdbc") return s.url ?? "";
if (v.driver === "sqlite") return `jdbc:sqlite:${s.file ?? ""}`;
const host = bracketed(s.host?.trim() || "localhost");
const port = s.port ?? v.port;
+14
View File
@@ -69,6 +69,10 @@
"Use URL template": "Use URL template",
"Use Driver": "Use Driver",
"Custom JDBC": "Custom JDBC",
"Data source type:": "Data source type:",
"Connection driver": "Connection driver",
"Built-in": "Built-in",
"Custom JDBC only": "Custom JDBC only",
"JDBC Driver Profiles": "JDBC Driver Profiles",
"Add JDBC Driver": "Add JDBC Driver",
"Edit JDBC Driver": "Edit JDBC Driver",
@@ -94,12 +98,22 @@
"Delete driver profile {name}? Data sources using it will need another driver profile.": "Delete driver profile {name}? Data sources using it will need another driver profile.",
"Choose a JDBC driver profile": "Choose a JDBC driver profile",
"Manage Drivers…": "Manage Drivers…",
"Go to Driver": "Go to Driver",
"Loading JDBC driver profiles…": "Loading JDBC driver profiles…",
"The JDBC driver profile is missing. Select or add a profile before connecting.": "The JDBC driver profile is missing. Select or add a profile before connecting.",
"The JDBC driver profile is assigned to a different data source type. Select a matching profile or update its type in Custom JDBC.": "The JDBC driver profile is assigned to a different data source type. Select a matching profile or update its type in Custom JDBC.",
"The URL and Advanced properties are saved with the data source. Enter passwords in the Password field.": "The URL and Advanced properties are saved with the data source. Enter passwords in the Password field.",
"For read-only access, use a database account with read-only privileges.": "For read-only access, use a database account with read-only privileges.",
"Review the JDBC URL, TLS settings and connection properties. If your native connection used an SSH tunnel, configure the equivalent route before connecting.": "Review the JDBC URL, TLS settings and connection properties. If your native connection used an SSH tunnel, configure the equivalent route before connecting.",
"I have configured JDBC connection security.": "I have configured JDBC connection security.",
"JDBC asks the driver for a read-only connection. Use a database account with read-only privileges.": "JDBC asks the driver for a read-only connection. Use a database account with read-only privileges.",
"JDBC uses auto-commit. Review your startup script, default schema, and time zone, and configure equivalent settings supported by your driver or database.": "JDBC uses auto-commit. Review your startup script, default schema, and time zone, and configure equivalent settings supported by your driver or database.",
"This source uses a separate credential for JDBC. Enter a password if your driver requires one.": "This source uses a separate credential for JDBC. Enter a password if your driver requires one.",
"The built-in driver restores the previous target and credentials. Review them before connecting.": "The built-in driver restores the previous target and credentials. Review them before connecting.",
"Sources that use this profile for its previous type will need a matching profile the next time they connect, including sources in other projects.": "Sources that use this profile for its previous type will need a matching profile the next time they connect, including sources in other projects.",
"If the connection used a password in the previous URL, enter it in the Password field.": "If the connection used a password in the previous URL, enter it in the Password field.",
"Review the built-in connection settings, credentials and TLS before connecting.": "Review the built-in connection settings, credentials and TLS before connecting.",
"I have configured built-in connection security.": "I have configured built-in connection security.",
"Passed to the JDBC driver as connection properties. Configure TLS and other driver-specific settings here or in the JDBC URL. Use the User and Password fields for credentials.": "Passed to the JDBC driver as connection properties. Configure TLS and other driver-specific settings here or in the JDBC URL. Use the User and Password fields for credentials.",
"Use the query console to change JDBC data.": "Use the query console to change JDBC data.",
"Presentation Assistant": "Presentation Assistant",
+14
View File
@@ -45,6 +45,10 @@
"Use URL template": "使用 URL 模板",
"Use Driver": "使用驱动程序",
"Custom JDBC": "自定义 JDBC",
"Data source type:": "数据源类型:",
"Connection driver": "连接驱动",
"Built-in": "内置",
"Custom JDBC only": "仅用于自定义 JDBC",
"JDBC Driver Profiles": "JDBC 驱动配置",
"Add JDBC Driver": "添加 JDBC 驱动",
"Edit JDBC Driver": "编辑 JDBC 驱动",
@@ -70,12 +74,22 @@
"Delete driver profile {name}? Data sources using it will need another driver profile.": "删除驱动配置 {name}?使用此配置的数据源需要重新选择驱动配置。",
"Choose a JDBC driver profile": "选择 JDBC 驱动配置",
"Manage Drivers…": "管理驱动…",
"Go to Driver": "转到驱动",
"Loading JDBC driver profiles…": "正在加载 JDBC 驱动配置…",
"The JDBC driver profile is missing. Select or add a profile before connecting.": "找不到此 JDBC 驱动配置。请先选择或添加配置再连接。",
"The JDBC driver profile is assigned to a different data source type. Select a matching profile or update its type in Custom JDBC.": "此 JDBC 驱动配置已关联到其他数据源类型。请选择匹配的配置,或在自定义 JDBC 中修改它的类型。",
"The URL and Advanced properties are saved with the data source. Enter passwords in the Password field.": "URL 和高级属性将随数据源保存。请在密码字段输入密码。",
"For read-only access, use a database account with read-only privileges.": "如需只读访问,请使用具有只读权限的数据库账号。",
"Review the JDBC URL, TLS settings and connection properties. If your native connection used an SSH tunnel, configure the equivalent route before connecting.": "请检查 JDBC URL、TLS 设置和连接属性。如果原生连接使用了 SSH 隧道,请在连接前配置相应的通道。",
"I have configured JDBC connection security.": "我已配置 JDBC 连接的安全设置。",
"JDBC asks the driver for a read-only connection. Use a database account with read-only privileges.": "JDBC 会请求驱动建立只读连接。请使用具备只读权限的数据库账号。",
"JDBC uses auto-commit. Review your startup script, default schema, and time zone, and configure equivalent settings supported by your driver or database.": "JDBC 使用自动提交。请检查启动脚本、默认模式和时区,并通过驱动或数据库配置相应的设置。",
"This source uses a separate credential for JDBC. Enter a password if your driver requires one.": "此数据源为 JDBC 使用单独的凭据。如果驱动需要密码,请输入密码。",
"The built-in driver restores the previous target and credentials. Review them before connecting.": "内置驱动会恢复之前的连接目标和凭据。请在连接前检查这些设置。",
"Sources that use this profile for its previous type will need a matching profile the next time they connect, including sources in other projects.": "使用此配置且仍为原数据源类型的数据源下次连接时需要匹配的配置,其中包括其他项目中的数据源。",
"If the connection used a password in the previous URL, enter it in the Password field.": "如果连接使用了原 URL 中的密码,请将其输入到密码字段。",
"Review the built-in connection settings, credentials and TLS before connecting.": "连接前请检查内置驱动的连接设置、凭据和 TLS。",
"I have configured built-in connection security.": "我已配置内置驱动的连接安全设置。",
"Passed to the JDBC driver as connection properties. Configure TLS and other driver-specific settings here or in the JDBC URL. Use the User and Password fields for credentials.": "作为连接属性传递给 JDBC 驱动。请在此处或 JDBC URL 中配置 TLS 和其他驱动专用设置。凭据请使用“用户”和“密码”字段。",
"Use the query console to change JDBC data.": "请使用查询控制台修改 JDBC 数据。",
"Presentation Assistant": "演示助手",