fix(oracle): support SYSDBA JDBC connections
This commit is contained in:
parent
763470e86d
commit
a95b82aea2
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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("""
|
||||
|
|
|
|||
Loading…
Reference in New Issue