com.mysql.cj

## Interface CharsetSettings

    public interface CharsetSettings

### Field Summary

Fields
`static String` `CHARACTER_SET_CLIENT`
`static String` `CHARACTER_SET_CONNECTION`
`static String` `CHARACTER_SET_RESULTS`
`static String` `COLLATION_CONNECTION`

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `configurePostHandshake(boolean dontCheckServerMatch)` Sets up client character set.
`int` `configurePreHandshake(boolean reset)` Choose the MySQL collation index for the handshake packet and the corresponding Java encodings for the password and error messages.
`boolean` `doesPlatformDbCharsetMatches()`
`Integer` `getCollationIndexForCollationName(String collationName)`
`int` `getCollationIndexForJavaEncoding(String javaEncoding, ServerVersion version)`
`int` `getCollationIndexForMysqlCharsetName(String charsetName)`
`String` `getCollationNameForCollationIndex(Integer collationIndex)`
`String` `getErrorMessageEncoding()`
`String` `getJavaEncodingForCollationIndex(int collationIndex)`
`String` `getJavaEncodingForMysqlCharset(String mysqlCharsetName)`
`int` `getMaxBytesPerChar(Integer charsetIndex, String javaCharsetName)`
`int` `getMaxBytesPerChar(String javaCharsetName)`
`int` `getMetadataCollationIndex()`
`String` `getMetadataEncoding()`
`String` `getMysqlCharsetForJavaEncoding(String javaEncoding, ServerVersion version)`
`String` `getMysqlCharsetNameForCollationIndex(Integer collationIndex)`
`String` `getPasswordCharacterEncoding()`
`boolean` `getRequiresEscapingEncoder()`
`boolean` `isMultibyteCharset(String javaEncodingName)`

### Field Detail

#### CHARACTER_SET_CLIENT

    static final String CHARACTER_SET_CLIENT

See Also:
  Constant Field Values

#### CHARACTER_SET_CONNECTION

    static final String CHARACTER_SET_CONNECTION

See Also:
  Constant Field Values

#### CHARACTER_SET_RESULTS

    static final String CHARACTER_SET_RESULTS

See Also:
  Constant Field Values

#### COLLATION_CONNECTION

    static final String COLLATION_CONNECTION

See Also:
  Constant Field Values

### Method Detail

#### configurePreHandshake

    int configurePreHandshake(boolean reset)

Choose the MySQL collation index for the handshake packet and the corresponding Java encodings for the password and error messages.

This index will be sent with HandshakeResponse setting server variables 'character_set_connection', 'collation_connection', 'character_set_client' and 'character_set_results' which will be used by the server for decoding passwords during the authentication phase and later on, if no SET NAMES are issued by `configurePostHandshake(boolean)`.

It also means that collation index should be set according to:

1. 'passwordCharacterEncoding' if it's present, or
2. 'connectionCollation' if it's present, or
3. 'characterEncoding' if it's present

otherwise it will be set to utf8mb4_general_ci or utf8mb4_0900_ai_ci depending on server version.

Since Protocol::HandshakeV10 and Protocol::HandshakeResponse41 use only one byte for the collation it's not possible to use indexes > 255 during the handshake. Also, ucs2, utf16, utf16le and utf32 character sets are impermissible here. Connector/J will try to use utf8mb4 instead.

Parameters:
  `reset` - reset the charsets configuration; needed for changeUser and resetServerState call.
Returns:
  MySQL collation index to be used during the handshake.

#### configurePostHandshake

    void configurePostHandshake(boolean dontCheckServerMatch)

Sets up client character set. This must be done before any further communication with the server! The 'collation_connection', 'character_set_client', 'character_set_connection' and 'character_set_results' server variables are set according to the collation index selected by `configurePreHandshake(boolean)` and sent in the Protocol::HandshakeV10 packet. Here Connector/J alters these server variables if needed.

Parameters:
  `dontCheckServerMatch` - if true then send the SET NAMES query even if server charset already matches the new value; needed for changeUser call.

#### doesPlatformDbCharsetMatches

    boolean doesPlatformDbCharsetMatches()

#### getPasswordCharacterEncoding

    String getPasswordCharacterEncoding()

#### getErrorMessageEncoding

    String getErrorMessageEncoding()

#### getMetadataEncoding

    String getMetadataEncoding()

#### getMetadataCollationIndex

    int getMetadataCollationIndex()

#### getRequiresEscapingEncoder

    boolean getRequiresEscapingEncoder()

#### getJavaEncodingForCollationIndex

    String getJavaEncodingForCollationIndex(int collationIndex)

#### getMaxBytesPerChar

    int getMaxBytesPerChar(String javaCharsetName)

#### getMaxBytesPerChar

    int getMaxBytesPerChar(Integer charsetIndex,
                           String javaCharsetName)

#### getCollationIndexForCollationName

    Integer getCollationIndexForCollationName(String collationName)

#### getCollationNameForCollationIndex

    String getCollationNameForCollationIndex(Integer collationIndex)

#### getMysqlCharsetNameForCollationIndex

    String getMysqlCharsetNameForCollationIndex(Integer collationIndex)

#### getCollationIndexForJavaEncoding

    int getCollationIndexForJavaEncoding(String javaEncoding,
                                         ServerVersion version)

#### getCollationIndexForMysqlCharsetName

    int getCollationIndexForMysqlCharsetName(String charsetName)

#### getJavaEncodingForMysqlCharset

    String getJavaEncodingForMysqlCharset(String mysqlCharsetName)

#### getMysqlCharsetForJavaEncoding

    String getMysqlCharsetForJavaEncoding(String javaEncoding,
                                          ServerVersion version)

#### isMultibyteCharset

    boolean isMultibyteCharset(String javaEncodingName)

Copyright © 2016, 2023, Oracle and/or its affiliates.