class SetupDataBaseService {

    public ServiceResult connectionTest(ConnectionRequest connectionRequest) {
        Connection conn = null;
        ResultSet rs = null;
        try {
            conn = DataSourceUtil.getConnection(connectionRequest.getDb_address(), connectionRequest.getDb_port(), connectionRequest.getDb_user(), DasEnv.encdecConfiguration.decrypt(connectionRequest.getDb_password()), DataBaseEnum.getDataBaseEnumByType(connectionRequest.getDb_type()).getDriver());
            rs = conn.getMetaData().getCatalogs();
            Set<String> allCatalog = new HashSet<>();
            while (rs.next()) {
                allCatalog.add(rs.getString("TABLE_CAT"));
            }
            return ServiceResult.success(allCatalog);
        } catch (Throwable e) {
            log.error(e.getMessage());
            return ServiceResult.fail(e.getMessage());
        } finally {
            DbUtil.close(rs);
            DbUtil.close(conn);
        }
    }

}