@@ -29,10 +29,11 @@ private OracleConstants() {
29
29
public static final String PLUGIN_NAME = "Oracle" ;
30
30
public static final String ORACLE_CONNECTION_STRING_SID_FORMAT = "jdbc:oracle:thin:@%s:%s:%s" ;
31
31
public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT = "jdbc:oracle:thin:@//%s:%s/%s" ;
32
- // Connection formats to accept protocol (e.g., jdbc:oracle:thin:@<protocol>://<host>:<port>/<SID>)
33
- public static final String ORACLE_CONNECTION_STRING_SID_FORMAT_WITH_PROTOCOL = "jdbc:oracle:thin:@%s:%s:%s/%s" ;
34
- public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT_WITH_PROTOCOL =
35
- "jdbc:oracle:thin:@%s://%s:%s/%s" ;
32
+ // Connection formats using TNS DESCRIPTOR to accept protocol
33
+ public static final String ORACLE_SERVICE_NAME_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL =
34
+ "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=%s)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SERVICE_NAME=%s)))" ;
35
+ public static final String ORACLE_SID_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL =
36
+ "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=%s)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SID=%s)))" ;
36
37
public static final String ORACLE_CONNECTION_STRING_TNS_FORMAT = "jdbc:oracle:thin:@%s" ;
37
38
public static final String DEFAULT_BATCH_VALUE = "defaultBatchValue" ;
38
39
public static final String DEFAULT_ROW_PREFETCH = "defaultRowPrefetch" ;
@@ -102,7 +103,8 @@ private static String getConnectionStringWithService(@Nullable String host,
102
103
boolean isSSLEnabled ) {
103
104
// Choose the appropriate format based on whether SSL is enabled.
104
105
if (isSSLEnabled ) {
105
- return String .format (OracleConstants .ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT_WITH_PROTOCOL ,
106
+ // Use the TNS descriptor format for TCPS to prevent automatic security injection.
107
+ return String .format (ORACLE_SERVICE_NAME_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL ,
106
108
connectionProtocol , host , port , database );
107
109
}
108
110
return String .format (OracleConstants .ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT ,
@@ -126,7 +128,8 @@ private static String getConnectionStringWithSID(@Nullable String host,
126
128
boolean isSSLEnabled ) {
127
129
// Choose the appropriate format based on whether SSL is enabled.
128
130
if (isSSLEnabled ) {
129
- return String .format (OracleConstants .ORACLE_CONNECTION_STRING_SID_FORMAT_WITH_PROTOCOL ,
131
+ // Use the TNS descriptor format for TCPS to prevent automatic security injection.
132
+ return String .format (ORACLE_SID_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL ,
130
133
connectionProtocol , host , port , database );
131
134
}
132
135
return String .format (OracleConstants .ORACLE_CONNECTION_STRING_SID_FORMAT ,
0 commit comments