laughingman7743 commented on code in PR #156:
URL:
https://github.com/apache/flink-connector-jdbc/pull/156#discussion_r2527584940
##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/core/database/catalog/AbstractJdbcCatalog.java:
##########
@@ -125,21 +125,27 @@ public AbstractJdbcCatalog(
checkNotNull(userClassLoader);
checkArgument(!StringUtils.isNullOrWhitespaceOnly(baseUrl));
- validateJdbcUrl(baseUrl);
-
this.userClassLoader = userClassLoader;
+ this.connectionProperties =
Preconditions.checkNotNull(connectionProperties);
this.baseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
this.defaultUrl = getDatabaseUrl(defaultDatabase);
- this.connectionProperties =
Preconditions.checkNotNull(connectionProperties);
- checkArgument(
-
!StringUtils.isNullOrWhitespaceOnly(connectionProperties.getProperty(USER_KEY)));
- checkArgument(
- !StringUtils.isNullOrWhitespaceOnly(
- connectionProperties.getProperty(PASSWORD_KEY)));
}
protected String getDatabaseUrl(String databaseName) {
- return baseUrl + databaseName;
+ // Check if base-url contains query parameters
+ int questionMarkIndex = baseUrl.indexOf('?');
+
+ if (questionMarkIndex == -1) {
+ // No parameters: traditional baseUrl + databaseName
+ return baseUrl + databaseName;
+ }
+
+ // Parameters present: insert database name before '?'
+ // Example: "jdbc:postgresql://localhost:5432/?sslmode=require"
+ // -> "jdbc:postgresql://localhost:5432/mydb?sslmode=require"
+ String urlWithoutParams = baseUrl.substring(0, questionMarkIndex);
+ String params = baseUrl.substring(questionMarkIndex);
+ return urlWithoutParams + databaseName + params;
Review Comment:
For Spanner tests, it is necessary to configure `autoConfigEmulator` to
automatically set up the emulator. This enables parameter passing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]