Top Fields Constructors Methods
org.apache.derby.shared.common.error

public Class MessageUtils

extends Object
Class Inheritance
Imports
java.lang.StringBuilder, java.math.BigDecimal, java.sql.DataTruncation, .SQLException, .SQLFeatureNotSupportedException, .SQLDataException, .SQLIntegrityConstraintViolationException, .SQLInvalidAuthorizationSpecException, .SQLNonTransientConnectionException, .SQLSyntaxErrorException, .SQLTimeoutException, .SQLTransactionRollbackException, java.text.MessageFormat, java.util.Locale, .MissingResourceException, .ResourceBundle, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.reference.SQLState

Field Summary

Modifier and TypeField and Description
public static final int
DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH

Pointer to the application requester for the session being serviced.

private static final Locale
public static final String
private static String
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER

SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER, When full message text is sent for severe errors.

public static String
SQLERRMC_TOKEN_DELIMITER

Delimiters for SQLERRMC values.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

the SQLERRMC string with all fields of the warning
buildDataTruncationSqlerrmc
(DataTruncation
the DataTruncation instance to serialize
dt
)

Build the SQLERRMC for a java.sql.DataTruncation warning.

private String

Returns:

preformated message text with messages separted by SQLERRMC_PREFORMATED_MESSAGE_DELIMITER
buildPreformattedSqlerrmc
(SQLException
SQLException for which to build SQLERRMC
se
)

Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions.

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

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

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

Method used by Derby Network Server to get localized message

public static String

Returns:

the localized message
getLocalizedMessage
(Locale
locale
locale
,
String
message id
messageId
,
Object[]
message arguments
args
)

Method used by Derby Network Server to get localized message

public static int

Returns:

the resulting hash
hashString50
(String
The key to hash
key
)

Hash function to split messages into 50 files based upon the message identifier or SQLState.

protected int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DB2_JCC_MAX_EXCEPTION_PARAM_LENGTHback to summary
public static final int DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH

Pointer to the application requester for the session being serviced.

ENback to summary
private static final Locale EN
SQLERRMC_MESSAGE_DELIMITERback to summary
public static final String SQLERRMC_MESSAGE_DELIMITER
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITERback to summary
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.

SQLERRMC_TOKEN_DELIMITERback to summary
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

Constructor Detail

MessageUtilsback to summary
public MessageUtils()

Method Detail

buildDataTruncationSqlerrmcback to summary
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:DataTruncation

the DataTruncation instance to serialize

Returns:String

the SQLERRMC string with all fields of the warning

buildPreformattedSqlerrmcback to summary
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

SQLException for which to build SQLERRMC

Returns:String

preformated message text with messages separted by SQLERRMC_PREFORMATED_MESSAGE_DELIMITER

encodeExceptionAsSqlerrmcback to summary
public static String encodeExceptionAsSqlerrmc(SQLException se)
encodeMessageAndArgumentsAsSqlerrmcback to summary
public static String encodeMessageAndArgumentsAsSqlerrmc(String messageId, Object[] args)
formatMessageback to summary
public static String formatMessage(ResourceBundle bundle, String messageId, Object[] arguments, boolean lastChance)
getArgsback to summary
public static Object[] getArgs(String sqlState, String sqlerrmc)
getLocalizedMessageback to summary
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:int

sqlcode, not used.

errmcLen:short

sqlerrmc length

sqlerrmc:String

sql error message tokens, variable part of error message (ie., arguments) plus messageId, separated by separator.

sqlerrp:String

not used

errd0:int

not used

errd1:int

not used

errd2:int

not used

errd3:int

not used

errd4:int

not used

errd5:int

not used

warn:String

not used

sqlState:String

5-char sql state

file:String

not used

localeStr:String

client locale in string

msg:String[]

OUTPUT parameter, localized error message

rc:int[]

OUTPUT parameter, return code -- 0 for success

getLocalizedMessageback to summary
public static String getLocalizedMessage(Locale locale, String messageId, Object[] args)

Method used by Derby Network Server to get localized message

Parameters
locale:Locale

locale

messageId:String

message id

args:Object[]

message arguments

Returns:String

the localized message

hashString50back to summary
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.

Parameters
key:String

The key to hash

Returns:int

the resulting hash

supportedMessageParamLengthback to summary
protected int supportedMessageParamLength()