-
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
Changes from all commits
8282947
d0acc07
4251ef4
8d79717
a4a325f
28c2324
e5d0f3c
ae6a467
660f26b
548e0df
73286f8
87105b6
92a0e4c
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,84 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) { | |
} | ||
return GENERIC_URL_LIKE.doParse(clickhouseUrl, builder); | ||
} | ||
}, | ||
/** | ||
* Sample urls: | ||
* | ||
* <ul> | ||
* <li>jdbc:oceanbase://host:port/dbname | ||
* <li>jdbc:oceanbase:oracle://host:port/dbname | ||
* </ul> | ||
*/ | ||
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); | ||
} | ||
Comment on lines
+931
to
+933
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 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. Yes, I've referred to |
||
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">Driver | ||
* configuration doc</a> | ||
* | ||
* <p>Sample urls: | ||
* | ||
* <ul> | ||
* <li>jdbc:lindorm:table:url=http//server_name:30060/test | ||
* <li>jdbc:lindorm:tsdb:url=http://server_name:8242/test | ||
* <li>jabc:lindorm:search:url=http://server_name:30070/test | ||
* </ul> | ||
*/ | ||
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); | ||
} | ||
}, | ||
/** Sample url: 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 +1021,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 +1183,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 +1209,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() {} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.