Class ExceptionFactory

  • Direct Known Subclasses:
    ExceptionFactory.SqlExceptionFactory

    public class ExceptionFactory
    extends java.lang.Object
    Exception factory. This permit common error logging, with thread id, dump query, and specific dead-lock additional information
    • Field Detail

      • LOCK_DEADLOCK_ERROR_CODES

        private static final java.util.Set<java.lang.Integer> LOCK_DEADLOCK_ERROR_CODES
      • threadId

        private long threadId
      • statement

        private java.sql.Statement statement
    • Constructor Detail

      • ExceptionFactory

        public ExceptionFactory​(Configuration conf,
                                HostAddress hostAddress)
        Connection Exception factory constructor
        Parameters:
        conf - configuration
        hostAddress - current host
    • Method Detail

      • buildMsgText

        private static java.lang.String buildMsgText​(java.lang.String initialMessage,
                                                     long threadId,
                                                     Configuration conf,
                                                     java.lang.String sql,
                                                     int errorCode,
                                                     Connection connection)
      • setConnection

        public void setConnection​(ExceptionFactory oldExceptionFactory)
        Set connection
        Parameters:
        oldExceptionFactory - previous connection exception factory
      • setThreadId

        public void setThreadId​(long threadId)
        Set connection thread id
        Parameters:
        threadId - connection thread id
      • createBatchUpdate

        public java.sql.BatchUpdateException createBatchUpdate​(java.util.List<Completion> res,
                                                               int length,
                                                               java.sql.SQLException sqle)
        Create a BatchUpdateException, filling successful updates
        Parameters:
        res - completion list
        length - expected size
        sqle - exception
        Returns:
        BatchUpdateException object
      • createBatchUpdate

        public java.sql.BatchUpdateException createBatchUpdate​(java.util.List<Completion> res,
                                                               int length,
                                                               int[] responseMsg,
                                                               java.sql.SQLException sqle)
        Create a BatchUpdateException, filling successful updates
        Parameters:
        res - completion list
        length - expected length
        responseMsg - successful response
        sqle - exception
        Returns:
        BatchUpdateException object
      • of

        public ExceptionFactory of​(java.sql.Statement statement)
        Construct an Exception factory from this + adding current statement
        Parameters:
        statement - current statement
        Returns:
        new Exception factory
      • withSql

        public ExceptionFactory withSql​(java.lang.String sql)
        Construct an Exception factory from this + adding current SQL
        Parameters:
        sql - current sql command
        Returns:
        new Exception factory
      • createException

        private java.sql.SQLException createException​(java.lang.String initialMessage,
                                                      java.lang.String sqlState,
                                                      int errorCode,
                                                      java.lang.Exception cause)
      • notSupported

        public java.sql.SQLException notSupported​(java.lang.String message)
        fast creation of SQLFeatureNotSupportedException exception
        Parameters:
        message - error message
        Returns:
        exception to be thrown
      • create

        public java.sql.SQLException create​(java.lang.String message)
        Creation of an exception
        Parameters:
        message - error message
        Returns:
        exception to be thrown
      • create

        public java.sql.SQLException create​(java.lang.String message,
                                            java.lang.String sqlState)
        Creation of an exception
        Parameters:
        message - error message
        sqlState - sql state
        Returns:
        exception to be thrown
      • create

        public java.sql.SQLException create​(java.lang.String message,
                                            java.lang.String sqlState,
                                            java.lang.Exception cause)
        Creation of an exception
        Parameters:
        message - error message
        sqlState - sql state
        cause - initial exception
        Returns:
        exception to be thrown
      • create

        public java.sql.SQLException create​(java.lang.String message,
                                            java.lang.String sqlState,
                                            int errorCode)
        Creation of an exception
        Parameters:
        message - error message
        sqlState - sql state
        errorCode - error code
        Returns:
        exception to be thrown
      • getSql

        public java.lang.String getSql()
        get SQL command
        Returns:
        sql command