Class OracleConnection

    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • ORACLE_UNSET_SCALE

        private static final int ORACLE_UNSET_SCALE
        Returned by column metadata in Oracle if no scale is set;
        See Also:
        Constant Field Values
      • SYS_NC_PATTERN

        private static final Pattern SYS_NC_PATTERN
        Pattern to identify system generated indices and column names.
      • URL

        private static final Field URL
        A field for the raw jdbc url. This field has no default value.
    • Method Detail

      • setSessionToPdb

        public void setSessionToPdb​(String pdbName)
      • resetSessionToCdb

        public void resetSessionToCdb()
      • getAllTableIds

        protected Set<TableId> getAllTableIds​(String catalogName)
                                       throws SQLException
        Retrieves all TableId in a given database catalog, filtering certain ids that should be omitted from the returned set such as special spatial tables and index-organized tables.
        Parameters:
        catalogName - the catalog/database name
        Returns:
        set of all table ids for existing table objects
        Throws:
        SQLException - if a database exception occurred
      • getCurrentScn

        public Scn getCurrentScn()
                          throws SQLException
        Get the current, most recent system change number.
        Returns:
        the current system change number
        Throws:
        SQLException - if an exception occurred
        IllegalStateException - if the query does not return at least one row
      • getMaxArchiveLogScn

        public Scn getMaxArchiveLogScn​(String archiveLogDestinationName)
                                throws SQLException
        Get the maximum system change number in the archive logs.
        Parameters:
        archiveLogDestinationName - the archive log destination name to be queried, can be null.
        Returns:
        the maximum system change number in the archive logs
        Throws:
        SQLException - if a database exception occurred
        io.debezium.DebeziumException - if the maximum archive log system change number could not be found
      • getTableMetadataDdl

        public String getTableMetadataDdl​(TableId tableId)
                                   throws SQLException
        Generate a given table's DDL metadata.
        Parameters:
        tableId - table identifier, should never be null
        Returns:
        generated DDL
        Throws:
        SQLException - if an exception occurred obtaining the DDL metadata
      • getSessionStatisticByName

        public Long getSessionStatisticByName​(String name)
                                       throws SQLException
        Get the current connection's session statistic by name.
        Parameters:
        name - the name of the statistic to be fetched, must not be null
        Returns:
        the session statistic value, never null
        Throws:
        SQLException - if an exception occurred obtaining the session statistic value
      • isTableExists

        public boolean isTableExists​(String tableName)
                              throws SQLException
        Returns whether the given table exists or not.
        Parameters:
        tableName - table name, should not be null
        Returns:
        true if the table exists, false if it does not
        Throws:
        SQLException - if a database exception occurred
      • isTableEmpty

        public boolean isTableEmpty​(String tableName)
                             throws SQLException
        Returns whether the given table is empty or not.
        Parameters:
        tableName - table name, should not be null
        Returns:
        true if the table has no records, false otherwise
        Throws:
        SQLException - if a database exception occurred
      • getRowCount

        public long getRowCount​(String tableName)
                         throws SQLException
        Returns the number of rows in a given table.
        Parameters:
        tableName - table name, should not be null
        Returns:
        the number of rows
        Throws:
        SQLException - if a database exception occurred
      • isArchiveLogMode

        protected boolean isArchiveLogMode()
        Determine whether the Oracle server has the archive log enabled.
        Returns:
        true if the server's LOG_MODE is set to ARCHIVELOG, or false otherwise
      • getScnToTimestamp

        public Optional<OffsetDateTime> getScnToTimestamp​(Scn scn)
                                                   throws SQLException
        Resolve a system change number to a timestamp, return value is in database timezone. The SCN to TIMESTAMP mapping is only retained for the duration of the flashback query area. This means that eventually the mapping between these values are no longer kept by Oracle and making a call with a SCN value that has aged out will result in an ORA-08181 error. This function explicitly checks for this use case and if a ORA-08181 error is thrown, it is therefore treated as if a value does not exist returning an empty optional value.
        Parameters:
        scn - the system change number, must not be null
        Returns:
        an optional timestamp when the system change number occurred
        Throws:
        SQLException - if a database exception occurred