Class JdbcUtils


  • public class JdbcUtils
    extends java.lang.Object
    • Field Detail

      • SLASH_DELIMITER_USER_PASSWORD_REGEX

        public static final java.lang.String SLASH_DELIMITER_USER_PASSWORD_REGEX
        See Also:
        Constant Field Values
      • COLON_DELIMITER_USER_PASSWORD_REGEX

        public static final java.lang.String COLON_DELIMITER_USER_PASSWORD_REGEX
        See Also:
        Constant Field Values
    • Constructor Detail

      • JdbcUtils

        public JdbcUtils()
    • Method Detail

      • sanitizeJdbcUrl

        public static java.lang.String sanitizeJdbcUrl​(java.lang.String jdbcUrl)
        JdbcUrl can contain username and password this method clean-up credentials from jdbcUrl and strip the jdbc prefix from the url
        Parameters:
        jdbcUrl - url to database
        Returns:
        String
      • getDatasetIdentifierFromJdbcUrl

        public static DatasetIdentifier getDatasetIdentifierFromJdbcUrl​(java.lang.String jdbcUrl,
                                                                        java.lang.String name)
      • getDatasetIdentifierFromJdbcUrl

        public static DatasetIdentifier getDatasetIdentifierFromJdbcUrl​(java.lang.String jdbcUrl,
                                                                        java.util.List<java.lang.String> parts)
        The algorithm for this method is as follows. First we parse URI and check if it includes path part of URI. If yes, then we check if it contains database. Database is the first part after slash in URI - the "db" in something like postgres://host:5432/db. If it does contain it, and provided parts list has less than three elements, then we use it as database part of name - this indicates that database is the default one in this context. Otherwise, we take database from parts list.
        Parameters:
        jdbcUrl - String URI we want to take dataset identifier from
        parts - Provided list of delimited parts of table qualified name parts. Can include database name.
        Returns:
        DatasetIdentifier