feat(sqlserver): add sql server 2000 legacy support
This commit is contained in:
20 files changed
+682
-24
No files matched your search
@@ -90,14 +90,26 @@ public abstract class AbstractJdbcAgent extends BaseDatabaseAgent {
|
||||
return unchecked(() -> {
|
||||
loadDriver(params);
|
||||
try (Connection conn = openTestConnection(params)) {
|
||||
String validationQuery = connectionValidationQuery();
|
||||
boolean valid = isConnectionValid(conn, 5);
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("ok", valid);
|
||||
result.put(
|
||||
"validation",
|
||||
validationQuery == null || validationQuery.isBlank() ? "jdbc_connection_isValid" : validationQuery
|
||||
);
|
||||
if (valid) {
|
||||
Map<String, String> databaseInfo = JdbcDatabaseInfo.from(conn);
|
||||
if (!databaseInfo.isEmpty()) {
|
||||
result.put("databaseInfo", databaseInfo);
|
||||
}
|
||||
} else {
|
||||
result.put(
|
||||
"error",
|
||||
"Connection opened, but validation failed (method: "
|
||||
+ (validationQuery == null || validationQuery.isBlank() ? "Connection.isValid" : validationQuery)
|
||||
+ ")"
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,8 @@ public final class JsonRpcServer {
|
||||
if (AgentProtocol.METHOD_TEST_CONNECTION.equals(method)) {
|
||||
Map<String, Object> result = agent.testConnectionWithInfo(gson.fromJson(params, ConnectParams.class));
|
||||
if (!Boolean.TRUE.equals(result.get("ok"))) {
|
||||
throw new RuntimeException("Connection failed");
|
||||
Object error = result.get("error");
|
||||
throw new RuntimeException(error == null ? "Connection failed" : String.valueOf(error));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user