Class DatabaseUtil

    • Method Detail

      • getType

        public static DatabaseUtil.DatabaseType getType​(Connection connection)
                                                 throws SQLException
        Determines the type of the given database
        Parameters:
        connection - The connection to the database
        Returns:
        The resulting type determination
        Throws:
        SQLException - if type determination fails, or if the DB is not a recognized type
      • isMicrosoft

        public static boolean isMicrosoft​(Connection connection)
                                   throws SQLException
        Determines if the given connection is to a Microsoft SQL Server database
        Parameters:
        connection - The connection to the database
        Returns:
        true if the database is Microsoft SQL Server, false otherwise
        Throws:
        SQLException - if the database type cannot be determined
      • isMysql

        public static boolean isMysql​(Connection connection)
                               throws SQLException
        Determines if the given connection is to a MySQL database
        Parameters:
        connection - The connection to the database
        Returns:
        true if the database is MySQL, false otherwise
        Throws:
        SQLException - if the database type cannot be determined
      • isOracle

        public static boolean isOracle​(Connection connection)
                                throws SQLException
        Determines if the given connection is to an Oracle database
        Parameters:
        connection - The connection to the database
        Returns:
        true if the database is Oracle, false otherwise
        Throws:
        SQLException - if the database type cannot be determined
      • isPostgres

        public static boolean isPostgres​(Connection connection)
                                  throws SQLException
        Determines if the given connection is to a PostgreSQL database
        Parameters:
        connection - The connection to the database
        Returns:
        true if the database is PostgreSQL, false otherwise
        Throws:
        SQLException - if the database type cannot be determined
      • isValidObjectName

        public static boolean isValidObjectName​(String name)
        Determines if the given name is a valid DB object name
        Parameters:
        name - The name to check
        Returns:
        true if the name is a valid object name, false otherwise
      • tableExists

        public static boolean tableExists​(Connection connection,
                                          String tableName)
        Returns true if the given table exists
        Parameters:
        connection - The connection to the database
        tableName - The name of the table to check
        Returns:
        true if the table exists, false otherwise