Class ExceptionMapper


  • public class ExceptionMapper
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Set<java.lang.Integer> LOCK_DEADLOCK_ERROR_CODES  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExceptionMapper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkConnectionException​(java.sql.SQLException exception, MariaDbConnection connection)
      Check connection exception to report to poolConnection listeners.
      static java.sql.SQLException connException​(java.lang.String message)  
      static java.sql.SQLException connException​(java.lang.String message, java.lang.Throwable cause)  
      static java.sql.SQLException get​(java.lang.String message, java.lang.String sqlState, int errorCode, java.lang.Throwable exception, boolean timeout)
      Helper to decorate exception with associate subclass of SQLException exception.
      static java.sql.SQLException getException​(java.sql.SQLException exception, MariaDbConnection connection, MariaDbStatement statement, boolean timeout)
      Helper to decorate exception with associate subclass of SQLException exception.
      static java.sql.SQLException getFeatureNotSupportedException​(java.lang.String message)  
      static java.sql.SQLException getSqlException​(java.lang.String message)  
      static java.sql.SQLException getSqlException​(java.lang.String message, java.lang.Exception exception)  
      static java.sql.SQLException getSqlException​(java.lang.String message, java.lang.String sqlState, java.lang.Exception exception)  
      static java.lang.String mapCodeToSqlState​(int code)
      Mapp code to State.
      static void throwException​(java.sql.SQLException exception, MariaDbConnection connection, MariaDbStatement statement)
      Helper to throw exception.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOCK_DEADLOCK_ERROR_CODES

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

      • ExceptionMapper

        public ExceptionMapper()
    • Method Detail

      • throwException

        public static void throwException​(java.sql.SQLException exception,
                                          MariaDbConnection connection,
                                          MariaDbStatement statement)
                                   throws java.sql.SQLException
        Helper to throw exception.
        Parameters:
        exception - exception
        connection - current connection
        statement - current statement
        Throws:
        java.sql.SQLException - exception
      • connException

        public static java.sql.SQLException connException​(java.lang.String message)
      • connException

        public static java.sql.SQLException connException​(java.lang.String message,
                                                          java.lang.Throwable cause)
      • getException

        public static java.sql.SQLException getException​(java.sql.SQLException exception,
                                                         MariaDbConnection connection,
                                                         MariaDbStatement statement,
                                                         boolean timeout)
        Helper to decorate exception with associate subclass of SQLException exception.
        Parameters:
        exception - exception
        connection - current connection
        statement - current statement
        timeout - was timeout on query
        Returns:
        SQLException exception
      • checkConnectionException

        public static void checkConnectionException​(java.sql.SQLException exception,
                                                    MariaDbConnection connection)
        Check connection exception to report to poolConnection listeners.
        Parameters:
        exception - current exception
        connection - current connection
      • get

        public static java.sql.SQLException get​(java.lang.String message,
                                                java.lang.String sqlState,
                                                int errorCode,
                                                java.lang.Throwable exception,
                                                boolean timeout)
        Helper to decorate exception with associate subclass of SQLException exception.
        Parameters:
        message - exception message
        sqlState - sqlstate
        errorCode - errorCode
        exception - cause
        timeout - was timeout on query
        Returns:
        SQLException exception
      • getSqlException

        public static java.sql.SQLException getSqlException​(java.lang.String message,
                                                            java.lang.Exception exception)
      • getSqlException

        public static java.sql.SQLException getSqlException​(java.lang.String message,
                                                            java.lang.String sqlState,
                                                            java.lang.Exception exception)
      • getSqlException

        public static java.sql.SQLException getSqlException​(java.lang.String message)
      • getFeatureNotSupportedException

        public static java.sql.SQLException getFeatureNotSupportedException​(java.lang.String message)
      • mapCodeToSqlState

        public static java.lang.String mapCodeToSqlState​(int code)
        Mapp code to State.
        Parameters:
        code - code
        Returns:
        String