Skip to content

Commit

Permalink
feat: 兼容taosdata数据库
Browse files Browse the repository at this point in the history
  • Loading branch information
Angle-bo authored and wenshao committed Oct 9, 2023
1 parent bda996c commit dbdd534
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/com/alibaba/druid/DbType.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public enum DbType {
interbase(0),
pointbase(0),
edbc(0),
mimer(0);
mimer(0),
taosdata(0);

public final long mask;
public final long hashCode64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ public PhysicalConnectionInfo createPhysicalConnection() throws SQLException {
if (socketTimeout > 0) {
physicalConnectProperties.put("socketTimeout", Long.toString(TimeUnit.MILLISECONDS.toSeconds(socketTimeout)));
}
} else if (DbType.sqlserver.name().equals(dbTypeName)) {
} else if (dbTypeName!=null && DbType.sqlserver.name().equals(dbTypeName)) {
// see https://learn.microsoft.com/en-us/sql/connect/jdbc/setting-the-connection-properties?view=sql-server-ver16
physicalConnectProperties.put("loginTimeout", Long.toString(TimeUnit.MILLISECONDS.toSeconds(connectTimeout)));
if (socketTimeout > 0) {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/com/alibaba/druid/util/JdbcConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,7 @@ public interface JdbcConstants {

DbType TYDB = DbType.tydb;
String TYDB_DRIVER = "com.dbcp.jdbc.Driver";

String TAOS_DATA = "com.taosdata.jdbc.TSDBDriver";
String TAOS_DATA_RS = "com.taosdata.jdbc.rs.RestfulDriver";
}
6 changes: 6 additions & 0 deletions core/src/main/java/com/alibaba/druid/util/JdbcUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ public static String getDriverClassName(String rawUrl) throws SQLException {
return JdbcConstants.TYDB_DRIVER;
} else if (rawUrl.startsWith("jdbc:opengauss:")) {
return "org.opengauss.Driver";
} else if (rawUrl.startsWith("jdbc:TAOS:")) {
return JdbcConstants.TAOS_DATA;
} else if (rawUrl.startsWith("jdbc:TAOS-RS:")) {
return JdbcConstants.TAOS_DATA_RS;
} else {
throw new SQLException("unknown jdbc driver : " + rawUrl);
}
Expand Down Expand Up @@ -650,6 +654,8 @@ public static DbType getDbTypeRaw(String rawUrl, String driverClassName) {
return DbType.greenplum;
} else if (rawUrl.startsWith("jdbc:opengauss:") || rawUrl.startsWith("jdbc:gaussdb:") || rawUrl.startsWith("jdbc:dws:iam:")) {
return DbType.gaussdb;
} else if (rawUrl.startsWith("jdbc:TAOS:")||rawUrl.startsWith("jdbc:TAOS-RS:")){
return DbType.taosdata;
} else {
return null;
}
Expand Down

0 comments on commit dbdd534

Please sign in to comment.