Top Fields Methods
com.mysql.cj

public Interface CharsetSettings

Known Direct Implementers
com.mysql.cj.NativeCharsetSettings

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String

Method Summary

Modifier and TypeMethod and Description
public void
configurePostHandshake(boolean
if true then send the SET NAMES query even if server charset already matches the new value; needed for changeUser call.
dontCheckServerMatch
)

Sets up client character set.

public int

Returns:

MySQL collation index to be used during the handshake.
configurePreHandshake
(boolean
reset the charsets configuration; needed for changeUser and resetServerState call.
reset
)

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

public boolean
public Integer
public int
public int
public String
public String
public String
public String
public int
getMaxBytesPerChar(String javaCharsetName)

public int
getMaxBytesPerChar(Integer charsetIndex, String javaCharsetName)

public int
public String
public String
public String
public String
public boolean
public boolean
isMultibyteCharset(String javaEncodingName)

Field Detail

CHARACTER_SET_CLIENTback to summary
public static final String CHARACTER_SET_CLIENT
CHARACTER_SET_CONNECTIONback to summary
public static final String CHARACTER_SET_CONNECTION
CHARACTER_SET_RESULTSback to summary
public static final String CHARACTER_SET_RESULTS
COLLATION_CONNECTIONback to summary
public static final String COLLATION_CONNECTION

Method Detail

configurePostHandshakeback to summary
public 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:boolean

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

configurePreHandshakeback to summary
public 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:boolean

reset the charsets configuration; needed for changeUser and resetServerState call.

Returns:int

MySQL collation index to be used during the handshake.

doesPlatformDbCharsetMatchesback to summary
public boolean doesPlatformDbCharsetMatches()
getCollationIndexForCollationNameback to summary
public Integer getCollationIndexForCollationName(String collationName)
getCollationIndexForJavaEncodingback to summary
public int getCollationIndexForJavaEncoding(String javaEncoding, ServerVersion version)
getCollationIndexForMysqlCharsetNameback to summary
public int getCollationIndexForMysqlCharsetName(String charsetName)
getCollationNameForCollationIndexback to summary
public String getCollationNameForCollationIndex(Integer collationIndex)
getErrorMessageEncodingback to summary
public String getErrorMessageEncoding()
getJavaEncodingForCollationIndexback to summary
public String getJavaEncodingForCollationIndex(int collationIndex)
getJavaEncodingForMysqlCharsetback to summary
public String getJavaEncodingForMysqlCharset(String mysqlCharsetName)
getMaxBytesPerCharback to summary
public int getMaxBytesPerChar(String javaCharsetName)
getMaxBytesPerCharback to summary
public int getMaxBytesPerChar(Integer charsetIndex, String javaCharsetName)
getMetadataCollationIndexback to summary
public int getMetadataCollationIndex()
getMetadataEncodingback to summary
public String getMetadataEncoding()
getMysqlCharsetForJavaEncodingback to summary
public String getMysqlCharsetForJavaEncoding(String javaEncoding, ServerVersion version)
getMysqlCharsetNameForCollationIndexback to summary
public String getMysqlCharsetNameForCollationIndex(Integer collationIndex)
getPasswordCharacterEncodingback to summary
public String getPasswordCharacterEncoding()
getRequiresEscapingEncoderback to summary
public boolean getRequiresEscapingEncoder()
isMultibyteCharsetback to summary
public boolean isMultibyteCharset(String javaEncodingName)