Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(oracle): support SYSDBA JDBC connections

t8y2a95b82aea202
diff --git a/crates/dbx-core/src/agent_connection.rs b/crates/dbx-core/src/agent_connection.rs
index eb10f16c74..0af703ac59 100644
--- a/crates/dbx-core/src/agent_connection.rs
+++ b/crates/dbx-core/src/agent_connection.rs
@@ -26,6 +26,7 @@ pub fn agent_connect_params(config: &ConnectionConfig, host: &str, port: u16, da
"database": agent_database,
"username": config.username,
"password": config.password,
+ "sysdba": config.sysdba,
"url_params": config.url_params.as_deref().unwrap_or(""),
"connection_string": connection_string,
})
diff --git a/crates/dbx-core/src/connection.rs b/crates/dbx-core/src/connection.rs
index 8d07283cdf..e44167c76f 100644
--- a/crates/dbx-core/src/connection.rs
+++ b/crates/dbx-core/src/connection.rs
@@ -1079,11 +1079,13 @@ mod tests {
config.port = 1521;
config.username = "system".to_string();
config.password = "oracle".to_string();
+ config.sysdba = true;
config.oracle_connection_type = Some("service_name".to_string());
let params = agent_connect_params(&config, "oracle.example.com", 1521, "ORCLPDB1");
assert_eq!(params["database"], "ORCLPDB1");
+ assert_eq!(params["sysdba"], true);
assert_eq!(params["connection_string"], "jdbc:oracle:thin:@//oracle.example.com:1521/ORCLPDB1");
}
diff --git a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java b/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java
index 790224a067..95b26cf888 100644
--- a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java
+++ b/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java
@@ -218,10 +218,7 @@ public final class DbxJdbcPlugin {
}
applyConnectTimeout(connection, properties);
if (isOracleUrl(url)) {
- properties.putIfAbsent("remarksReporting", "false");
- properties.putIfAbsent("restrictGetTables", "true");
- properties.putIfAbsent("includeSynonyms", "false");
- properties.putIfAbsent("oracle.jdbc.defaultRowPrefetch", "100");
+ applyOracleProperties(connection, properties);
}
sharedConnection = DriverManager.getConnection(url, properties);
sharedConnectionKey = key;
@@ -236,6 +233,16 @@ public final class DbxJdbcPlugin {
properties.putIfAbsent("connectTimeout", value);
}
+ private static void applyOracleProperties(JsonNode connection, Properties properties) {
+ properties.putIfAbsent("remarksReporting", "false");
+ properties.putIfAbsent("restrictGetTables", "true");
+ properties.putIfAbsent("includeSynonyms", "false");
+ properties.putIfAbsent("oracle.jdbc.defaultRowPrefetch", "100");
+ if (connection.path("sysdba").asBoolean(false)) {
+ properties.putIfAbsent("internal_logon", "sysdba");
+ }
+ }
+
private static JsonNode executeQuery(
JsonNode connection,
String sql,
@@ -579,7 +586,10 @@ public final class DbxJdbcPlugin {
}
private static String connectionKey(JsonNode connection) {
- return optionalText(connection, "connection_string") + "|" + optionalText(connection, "username") + "|" + optionalText(connection, "password");
+ return optionalText(connection, "connection_string")
+ + "|" + optionalText(connection, "username")
+ + "|" + optionalText(connection, "password")
+ + "|" + connection.path("sysdba").asBoolean(false);
}
private static Set<String> primaryKeys(DatabaseMetaData meta, String database, String schema, String table) throws SQLException {
diff --git a/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java b/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java
index d115a4f63b..504605b7df 100644
--- a/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java
+++ b/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java
@@ -122,6 +122,20 @@ final class DbxJdbcPluginTest {
assertEquals("45", properties.getProperty("connectTimeout"));
}
+ @Test
+ void oracleSysdbaIsMappedToInternalLogonProperty() throws Exception {
+ Method method = DbxJdbcPlugin.class.getDeclaredMethod("applyOracleProperties", JsonNode.class, Properties.class);
+ method.setAccessible(true);
+ Properties properties = new Properties();
+ JsonNode connection = MAPPER.readTree("""
+ { "sysdba": true }
+ """);
+
+ method.invoke(null, connection, properties);
+
+ assertEquals("sysdba", properties.getProperty("internal_logon"));
+ }
+
@Test
void driverQuirksDetectYashanJdbcUrl() throws Exception {
JsonNode yashan = MAPPER.readTree("""