-
Notifications
You must be signed in to change notification settings - Fork 1k
Add JDBC URL parsing support for OceanBase, PolarDB and Lindorm #14790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8282947
d0acc07
4251ef4
8d79717
a4a325f
28c2324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -911,6 +911,72 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) { | |||||
} | ||||||
return GENERIC_URL_LIKE.doParse(clickhouseUrl, builder); | ||||||
} | ||||||
}, | ||||||
/** jdbc:oceanbase://host:port/dbname jdbc:oceanbase:oracle://host:port/dbname */ | ||||||
OCEANBASE("oceanbase") { | ||||||
@Override | ||||||
DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) { | ||||||
int protoLoc = jdbcUrl.indexOf("://"); | ||||||
int typeEndLoc = jdbcUrl.indexOf(':'); | ||||||
if (protoLoc > typeEndLoc) { | ||||||
String subtype = jdbcUrl.substring(typeEndLoc + 1, protoLoc); | ||||||
builder.subtype(subtype); | ||||||
if (subtype.equals(DbSystemValues.ORACLE)) { | ||||||
builder.system(DbSystemValues.ORACLE); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is oracle the only supported subtype? |
||||||
} | ||||||
Comment on lines
+924
to
+926
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initially I though that it is weird to have |
||||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder); | ||||||
} else { | ||||||
return GENERIC_URL_LIKE.doParse(jdbcUrl, builder); | ||||||
} | ||||||
} | ||||||
}, | ||||||
/** | ||||||
* <a | ||||||
* href="https://www.alibabacloud.com/help/en/lindorm/user-guide/view-endpoints?spm=a2c63.p38356.help-menu-172543.d_2_0_1.7a1e41feMntzyJ">Driver | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deleted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
did you forget to actually delete the url parameters? |
||||||
* configuration doc</a> jdbc:lindorm:table:url=http//server_name:30060/test | ||||||
* jdbc:lindorm:tsdb:url=http://server_name:8242/test | ||||||
* jabc:lindorm:search:url=http://server_name:30070/test | ||||||
*/ | ||||||
LINDORM("lindorm") { | ||||||
private static final String DEFAULT_HOST = "localhost"; | ||||||
private static final int DEFAULT_PORT = 30060; | ||||||
|
||||||
@Override | ||||||
DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) { | ||||||
String lindormUrl = jdbcUrl.substring("lindorm:".length()); | ||||||
DbInfo dbInfo = builder.build(); | ||||||
if (dbInfo.getHost() == null) { | ||||||
builder.host(DEFAULT_HOST); | ||||||
} | ||||||
if (dbInfo.getPort() == null) { | ||||||
builder.port(DEFAULT_PORT); | ||||||
} | ||||||
|
||||||
int urlIndex = lindormUrl.indexOf(":url="); | ||||||
if (urlIndex < 0) { | ||||||
return builder; | ||||||
} | ||||||
builder.subtype(lindormUrl.substring(0, urlIndex)); | ||||||
String realUrl = lindormUrl.substring(urlIndex + 5); | ||||||
return GENERIC_URL_LIKE.doParse(realUrl, builder); | ||||||
} | ||||||
}, | ||||||
/** jdbc:polardb://server_name:1901/dbname */ | ||||||
POLARDB("polardb") { | ||||||
private static final int DEFAULT_PORT = 1521; | ||||||
private static final String DEFAULT_HOST = "localhost"; | ||||||
|
||||||
@Override | ||||||
DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) { | ||||||
DbInfo dbInfo = builder.build(); | ||||||
if (dbInfo.getHost() == null) { | ||||||
builder.host(DEFAULT_HOST); | ||||||
} | ||||||
if (dbInfo.getPort() == null) { | ||||||
builder.port(DEFAULT_PORT); | ||||||
} | ||||||
return GENERIC_URL_LIKE.doParse(jdbcUrl, builder); | ||||||
} | ||||||
}; | ||||||
|
||||||
private static final Logger logger = Logger.getLogger(JdbcConnectionUrlParser.class.getName()); | ||||||
|
@@ -943,8 +1009,13 @@ public static DbInfo parse(String connectionUrl, Properties props) { | |||||
connectionUrl = connectionUrl.toLowerCase(Locale.ROOT); | ||||||
|
||||||
String jdbcUrl; | ||||||
if (connectionUrl.startsWith("jdbc:")) { | ||||||
if (connectionUrl.startsWith("jdbc:tracing:")) { | ||||||
// see https://github.com/opentracing-contrib/java-jdbc | ||||||
jdbcUrl = connectionUrl.substring("jdbc:tracing:".length()); | ||||||
} else if (connectionUrl.startsWith("jdbc:")) { | ||||||
jdbcUrl = connectionUrl.substring("jdbc:".length()); | ||||||
} else if (connectionUrl.startsWith("jdbc-secretsmanager:tracing:")) { | ||||||
jdbcUrl = connectionUrl.substring("jdbc-secretsmanager:tracing:".length()); | ||||||
} else if (connectionUrl.startsWith("jdbc-secretsmanager:")) { | ||||||
jdbcUrl = connectionUrl.substring("jdbc-secretsmanager:".length()); | ||||||
} else { | ||||||
|
@@ -1100,6 +1171,12 @@ private static String toDbSystem(String type) { | |||||
return DbSystemValues.HANADB; | ||||||
case "clickhouse": // ClickHouse | ||||||
return DbSystemValues.CLICKHOUSE; | ||||||
case "oceanbase": // Oceanbase | ||||||
return DbSystemValues.OCEANBASE; | ||||||
case "polardb": // PolarDB | ||||||
return DbSystemValues.POLARDB; | ||||||
case "lindorm": // Lindorm | ||||||
return DbSystemValues.LINDORM; | ||||||
default: | ||||||
return DbSystemValues.OTHER_SQL; // Unknown DBMS | ||||||
} | ||||||
|
@@ -1120,6 +1197,9 @@ private static final class DbSystemValues { | |||||
static final String MARIADB = "mariadb"; | ||||||
static final String H2 = "h2"; | ||||||
static final String CLICKHOUSE = "clickhouse"; | ||||||
static final String OCEANBASE = "oceanbase"; | ||||||
static final String POLARDB = "polardb"; | ||||||
static final String LINDORM = "lindorm"; | ||||||
|
||||||
private DbSystemValues() {} | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps change the comment to