Class MessageUtils

java.lang.Object
org.apache.derby.shared.common.error.MessageUtils

public class MessageUtils extends Object
  • Field Details

    • EN

      private static final Locale EN
    • SQLERRMC_MESSAGE_DELIMITER

      public static final String SQLERRMC_MESSAGE_DELIMITER
    • DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH

      public static final int DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH
      Pointer to the application requester for the session being serviced.
      See Also:
    • SQLERRMC_TOKEN_DELIMITER

      public static String SQLERRMC_TOKEN_DELIMITER
      Delimiters for SQLERRMC values. The token delimiter value will be used to parse the MessageId from the SQLERRMC in MessageService.getLocalizedMessage and the MessageId will be used to retrive the localized message. If this delimiter value is changed please make sure to make appropriate changes in MessageService.getLocalizedMessage that gets called from SystemProcedures.SQLCAMESSAGE SQLERRMC_TOKEN_DELIMITER separates message argument tokens
    • SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER

      private static String SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
      SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER, When full message text is sent for severe errors. This value separates the messages.
  • Constructor Details

    • MessageUtils

      public MessageUtils()
  • Method Details

    • supportedMessageParamLength

      protected int supportedMessageParamLength()
    • getArgs

      public static Object[] getArgs(String sqlState, String sqlerrmc)
    • encodeMessageAndArgumentsAsSqlerrmc

      public static String encodeMessageAndArgumentsAsSqlerrmc(String messageId, Object[] args)
    • encodeExceptionAsSqlerrmc

      public static String encodeExceptionAsSqlerrmc(SQLException se)
    • buildDataTruncationSqlerrmc

      private String buildDataTruncationSqlerrmc(DataTruncation dt)
      Build the SQLERRMC for a java.sql.DataTruncation warning. Serialize all the fields of the DataTruncation instance in the order in which they appear in the parameter list of the constructor.
      Parameters:
      dt - the DataTruncation instance to serialize
      Returns:
      the SQLERRMC string with all fields of the warning
    • buildPreformattedSqlerrmc

      private String buildPreformattedSqlerrmc(SQLException se)
      Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions. Just send the message text localized to the server locale.
      Parameters:
      se - SQLException for which to build SQLERRMC
      Returns:
      preformated message text with messages separted by SQLERRMC_PREFORMATED_MESSAGE_DELIMITER
    • hashString50

      public static int hashString50(String key)
      Hash function to split messages into 50 files based upon the message identifier or SQLState. We don't use String.hashCode() as it varies between releases and doesn't provide an even distribution across the 50 files.
    • getBundleWithEnDefault

      public static ResourceBundle getBundleWithEnDefault(String resource, Locale locale)
      Method to use instead of ResourceBundle.getBundle(). This method acts like ResourceBundle. getBundle() but if the resource is not available in the requested locale, default locale or base class the one for en_US is returned.
    • getBundleForLocale

      public static ResourceBundle getBundleForLocale(Locale locale, String msgId)
    • formatMessage

      public static String formatMessage(ResourceBundle bundle, String messageId, Object[] arguments, boolean lastChance)
    • getLocalizedMessage

      public static void getLocalizedMessage(int sqlcode, short errmcLen, String sqlerrmc, String sqlerrp, int errd0, int errd1, int errd2, int errd3, int errd4, int errd5, String warn, String sqlState, String file, String localeStr, String[] msg, int[] rc)
      Method used by Derby Network Server to get localized message
      Parameters:
      sqlcode - sqlcode, not used.
      errmcLen - sqlerrmc length
      sqlerrmc - sql error message tokens, variable part of error message (ie., arguments) plus messageId, separated by separator.
      sqlerrp - not used
      errd0 - not used
      warn - not used
      sqlState - 5-char sql state
      file - not used
      localeStr - client locale in string
      msg - OUTPUT parameter, localized error message
      rc - OUTPUT parameter, return code -- 0 for success
    • getLocalizedMessage

      public static String getLocalizedMessage(Locale locale, String messageId, Object[] args)
      Method used by Derby Network Server to get localized message
      Parameters:
      locale - locale
      messageId - message id
      args - message arguments