public static JdbcUrlUtil.UrlInfo parse(String url) {
        String serverName = "";
        Integer port = DEFAULT_PORT;
        String dbInstance = null;
        int hostIndex = url.indexOf("://");
        if (hostIndex <= 0) {
            return null;
        }

        Map<String, String> props = Collections.emptyMap();
        String[] split = url.split(";", 2);
        if (split.length > 1) {
            props = parseQueryParams(split[1], ";");
            serverName = props.get("serverName");
            dbInstance = props.getOrDefault("databaseName", props.get("database"));
            if (props.containsKey("portNumber")) {
                String portNumber = props.get("portNumber");
                try {
                    port = Integer.parseInt(portNumber);
                } catch (NumberFormatException e) {
                }
            }
        }

        String urlServerName = split[0].substring(hostIndex + 3);
        if (!urlServerName.isEmpty()) {
            serverName = urlServerName;
        }

        int portLoc = serverName.indexOf(":");
        if (portLoc > 1) {
            port = Integer.parseInt(serverName.substring(portLoc + 1));
            serverName = serverName.substring(0, portLoc);
        }

        int instanceLoc = serverName.indexOf("\\");
        if (instanceLoc > 1) {
            serverName = serverName.substring(0, instanceLoc);
        }

        if (serverName.isEmpty()) {
            return null;
        }

        String suffix =
                props.entrySet().stream()
                        .filter(
                                e ->
                                        !e.getKey().equals("databaseName")
                                                && !e.getKey().equals("database"))
                        .map(e -> e.getKey() + "=" + e.getValue())
                        .collect(Collectors.joining(";", "", ""));
        suffix = Optional.ofNullable(suffix).orElse("");
        return new JdbcUrlUtil.UrlInfo(
                url,
                String.format("jdbc:sqlserver://%s:%s", serverName, port) + ";" + suffix,
                serverName,
                port,
                dbInstance,
                suffix);
    }
@Test
    public void testParse() {
        String url =
                "jdbc:sqlserver://localhost:1433;databaseName=myDB;encrypt=true;trustServerCertificate=false;loginTimeout=30;";
        JdbcUrlUtil.UrlInfo urlInfo = SqlServerURLParser.parse(url);
        assertEquals("localhost", urlInfo.getHost());
        assertEquals(1433, urlInfo.getPort());
        assertEquals(url, urlInfo.getOrigin());
        assertEquals(
                "encrypt=true;trustServerCertificate=false;loginTimeout=30", urlInfo.getSuffix());
        assertEquals("myDB", urlInfo.getDefaultDatabase().get());
        assertEquals(
                "jdbc:sqlserver://localhost:1433;encrypt=true;trustServerCertificate=false;loginTimeout=30",
                urlInfo.getUrlWithoutDatabase());
    }