@@ -911,6 +911,84 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
911
911
}
912
912
return GENERIC_URL_LIKE .doParse (clickhouseUrl , builder );
913
913
}
914
+ },
915
+ /**
916
+ * Sample urls:
917
+ *
918
+ * <ul>
919
+ * <li>jdbc:oceanbase://host:port/dbname
920
+ * <li>jdbc:oceanbase:oracle://host:port/dbname
921
+ * </ul>
922
+ */
923
+ OCEANBASE ("oceanbase" ) {
924
+ @ Override
925
+ DbInfo .Builder doParse (String jdbcUrl , DbInfo .Builder builder ) {
926
+ int protoLoc = jdbcUrl .indexOf ("://" );
927
+ int typeEndLoc = jdbcUrl .indexOf (':' );
928
+ if (protoLoc > typeEndLoc ) {
929
+ String subtype = jdbcUrl .substring (typeEndLoc + 1 , protoLoc );
930
+ builder .subtype (subtype );
931
+ if (subtype .equals (DbSystemValues .ORACLE )) {
932
+ builder .system (DbSystemValues .ORACLE );
933
+ }
934
+ return MODIFIED_URL_LIKE .doParse (jdbcUrl , builder );
935
+ } else {
936
+ return GENERIC_URL_LIKE .doParse (jdbcUrl , builder );
937
+ }
938
+ }
939
+ },
940
+ /**
941
+ * <a href="https://www.alibabacloud.com/help/en/lindorm/user-guide/view-endpoints">Driver
942
+ * configuration doc</a>
943
+ *
944
+ * <p>Sample urls:
945
+ *
946
+ * <ul>
947
+ * <li>jdbc:lindorm:table:url=http//server_name:30060/test
948
+ * <li>jdbc:lindorm:tsdb:url=http://server_name:8242/test
949
+ * <li>jabc:lindorm:search:url=http://server_name:30070/test
950
+ * </ul>
951
+ */
952
+ LINDORM ("lindorm" ) {
953
+ private static final String DEFAULT_HOST = "localhost" ;
954
+ private static final int DEFAULT_PORT = 30060 ;
955
+
956
+ @ Override
957
+ DbInfo .Builder doParse (String jdbcUrl , DbInfo .Builder builder ) {
958
+ String lindormUrl = jdbcUrl .substring ("lindorm:" .length ());
959
+ DbInfo dbInfo = builder .build ();
960
+ if (dbInfo .getHost () == null ) {
961
+ builder .host (DEFAULT_HOST );
962
+ }
963
+ if (dbInfo .getPort () == null ) {
964
+ builder .port (DEFAULT_PORT );
965
+ }
966
+
967
+ int urlIndex = lindormUrl .indexOf (":url=" );
968
+ if (urlIndex < 0 ) {
969
+ return builder ;
970
+ }
971
+ builder .subtype (lindormUrl .substring (0 , urlIndex ));
972
+ String realUrl = lindormUrl .substring (urlIndex + 5 );
973
+ return GENERIC_URL_LIKE .doParse (realUrl , builder );
974
+ }
975
+ },
976
+ /** Sample url: jdbc:polardb://server_name:1901/dbname */
977
+ POLARDB ("polardb" ) {
978
+ private static final int DEFAULT_PORT = 1521 ;
979
+ private static final String DEFAULT_HOST = "localhost" ;
980
+
981
+ @ Override
982
+ DbInfo .Builder doParse (String jdbcUrl , DbInfo .Builder builder ) {
983
+ DbInfo dbInfo = builder .build ();
984
+ if (dbInfo .getHost () == null ) {
985
+ builder .host (DEFAULT_HOST );
986
+ }
987
+ if (dbInfo .getPort () == null ) {
988
+ builder .port (DEFAULT_PORT );
989
+ }
990
+ return GENERIC_URL_LIKE .doParse (jdbcUrl , builder );
991
+ }
914
992
};
915
993
916
994
private static final Logger logger = Logger .getLogger (JdbcConnectionUrlParser .class .getName ());
@@ -943,8 +1021,13 @@ public static DbInfo parse(String connectionUrl, Properties props) {
943
1021
connectionUrl = connectionUrl .toLowerCase (Locale .ROOT );
944
1022
945
1023
String jdbcUrl ;
946
- if (connectionUrl .startsWith ("jdbc:" )) {
1024
+ if (connectionUrl .startsWith ("jdbc:tracing:" )) {
1025
+ // see https://github.com/opentracing-contrib/java-jdbc
1026
+ jdbcUrl = connectionUrl .substring ("jdbc:tracing:" .length ());
1027
+ } else if (connectionUrl .startsWith ("jdbc:" )) {
947
1028
jdbcUrl = connectionUrl .substring ("jdbc:" .length ());
1029
+ } else if (connectionUrl .startsWith ("jdbc-secretsmanager:tracing:" )) {
1030
+ jdbcUrl = connectionUrl .substring ("jdbc-secretsmanager:tracing:" .length ());
948
1031
} else if (connectionUrl .startsWith ("jdbc-secretsmanager:" )) {
949
1032
jdbcUrl = connectionUrl .substring ("jdbc-secretsmanager:" .length ());
950
1033
} else {
@@ -1100,6 +1183,12 @@ private static String toDbSystem(String type) {
1100
1183
return DbSystemValues .HANADB ;
1101
1184
case "clickhouse" : // ClickHouse
1102
1185
return DbSystemValues .CLICKHOUSE ;
1186
+ case "oceanbase" : // Oceanbase
1187
+ return DbSystemValues .OCEANBASE ;
1188
+ case "polardb" : // PolarDB
1189
+ return DbSystemValues .POLARDB ;
1190
+ case "lindorm" : // Lindorm
1191
+ return DbSystemValues .LINDORM ;
1103
1192
default :
1104
1193
return DbSystemValues .OTHER_SQL ; // Unknown DBMS
1105
1194
}
@@ -1120,6 +1209,9 @@ private static final class DbSystemValues {
1120
1209
static final String MARIADB = "mariadb" ;
1121
1210
static final String H2 = "h2" ;
1122
1211
static final String CLICKHOUSE = "clickhouse" ;
1212
+ static final String OCEANBASE = "oceanbase" ;
1213
+ static final String POLARDB = "polardb" ;
1214
+ static final String LINDORM = "lindorm" ;
1123
1215
1124
1216
private DbSystemValues () {}
1125
1217
}
0 commit comments