<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.5</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.3.5</version>
</dependency>
private Map<Object, Object> testConn(SysDatasource sysDatasource) {
Map<Object, Object> result = new HashMap<>();
if ("".equals(sysDatasource.getDatabaseName()) || null == sysDatasource.getDatabaseName()) {
result.put("Response", Response.builderFail("1", "库名不能为空"));
return result;
}
String path = "/data/temp";
String dataType = sysDatasource.getDatasourceType();
String username = sysDatasource.getUsername();
String password = sysDatasource.getPassword();
String ip = sysDatasource.getHost();
Integer port = sysDatasource.getPort();
String databaseName = sysDatasource.getDatabaseName();
String url = "";
String configParam = sysDatasource.getConfigParam();
String connectParam = sysDatasource.getConnectParam();
StringBuilder param = new StringBuilder();
boolean flag = false;
if (!"".equals(connectParam) && null != connectParam) {
flag = true;
JSONObject map = JSONUtil.parseObj(connectParam);
for (Object obj : map.entrySet()) {
param.append(obj).append("&");
}
if (-1 != param.lastIndexOf("&")) {
param.deleteCharAt(param.lastIndexOf("&"));
}
}
switch (dataType) {
case "MYSQL":
case "Apache Doris":
url = flag ? "jdbc:mysql://" + ip + ":" + port + "/" + databaseName + "?" + param : "jdbc:mysql://" + ip + ":" + port + "/" + databaseName;
result.put("Response", conn(url, username, password)