public static Connection getConnectionWithRetry(String driverName,
                                                    String url,
                                                    String userName,
                                                    String password) {
        String message = "Get connection failed. " +
            "\nurl: [%s]" +
            "\nuserName: [%s]" +
            "\ncause: [%s]";
        String errorCause;
        String errorMessage = "";

        ClassLoaderManager.forName(driverName, JdbcConnectionUtil.class.getClassLoader());
        Preconditions.checkNotNull(url, "url can't be null!");

        for (int i = 0; i < DEFAULT_RETRY_NUM; i++) {
            try {
                Connection connection =
                    Objects.isNull(userName) ?
                        DriverManager.getConnection(url) :
                        DriverManager.getConnection(url, userName, password);
                connection.setAutoCommit(false);
                return connection;
            } catch (Exception e) {
                errorCause = ExceptionTrace.traceOriginalCause(e);
                errorMessage = String.format(
                    message,
                    url,
                    userName,
                    errorCause
                );
                LOG.warn(errorMessage);
                LOG.warn("Connect will retry after [{}] s. Retry time [{}] ...", DEFAULT_RETRY_TIME_WAIT, i + 1);
                ThreadUtil.sleepSeconds(DEFAULT_RETRY_TIME_WAIT);
            }
        }
        throw new SuppressRestartsException(new SQLException(errorMessage));
    }
get connection from datasource and retry when failed.

@param driverName driver name for rdb datasource
@param url        connect url
@param userName   connect user name
@param password   password for user name
@return a valid connection
rdb/rdb-core/src/main/java/com/dtstack/flink/sql/core/rdb/util/JdbcConnectionUtil.java