public class NativeCharsetSettings extends CharsetMapping implements CharsetSettings
| Modifier and Type | Field and Description |
|---|---|
protected RuntimeProperty<java.lang.Boolean> |
cacheServerConfiguration |
protected RuntimeProperty<java.lang.String> |
characterEncoding |
protected RuntimeProperty<java.lang.String> |
characterSetResults |
java.util.Map<java.lang.String,java.lang.Integer> |
charsetNameToCollationIndex |
java.util.Map<java.lang.String,java.lang.String> |
charsetNameToJavaEncoding |
java.util.Map<java.lang.String,java.lang.Integer> |
charsetNameToMblen |
java.util.Map<java.lang.Integer,java.lang.String> |
collationIndexToCharsetName |
java.util.Map<java.lang.Integer,java.lang.String> |
collationIndexToCollationName |
java.util.Map<java.lang.String,java.lang.Integer> |
collationNameToCollationIndex |
private NativeMessageBuilder |
commandBuilder |
protected RuntimeProperty<java.lang.String> |
connectionCollation |
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> |
customCharsetNameToCollationIndexByUrl |
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
customCharsetNameToJavaEncodingByUrl |
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> |
customCharsetNameToMblenByUrl
Actual mysql charset name to mblen map of user defined charsets for given server URLs.
|
private static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.String>> |
customCollationIndexToCharsetNameByUrl
Actual collation index to mysql charset name map of user defined charsets for given server URLs.
|
private static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.String>> |
customCollationIndexToCollationNameByUrl |
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> |
customCollationNameToCollationIndexByUrl |
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
customJavaEncodingUcToCharsetNameByUrl |
private static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
customMultibyteEncodingsByUrl |
private java.lang.String |
errorMessageEncoding
The (Java) encoding used to interpret error messages received from the server.
|
java.util.Map<java.lang.String,java.lang.String> |
javaEncodingUcToCharsetName |
private int |
metadataCollationIndex |
private java.lang.String |
metadataEncoding
What character set is the metadata returned in?
|
java.util.Set<java.lang.String> |
multibyteEncodings |
protected RuntimeProperty<java.lang.String> |
passwordCharacterEncoding |
private boolean |
platformDbCharsetMatches
Does the character set of this connection match the character set of the platform
|
private boolean |
requiresEscapingEncoder
If a CharsetEncoder is required for escaping.
|
private ServerSession |
serverSession |
private NativeSession |
session |
private java.lang.Integer |
sessionCollationIndex |
MAP_SIZE, MYSQL_CHARSET_NAME_armscii8, MYSQL_CHARSET_NAME_ascii, MYSQL_CHARSET_NAME_big5, MYSQL_CHARSET_NAME_binary, MYSQL_CHARSET_NAME_cp1250, MYSQL_CHARSET_NAME_cp1251, MYSQL_CHARSET_NAME_cp1256, MYSQL_CHARSET_NAME_cp1257, MYSQL_CHARSET_NAME_cp850, MYSQL_CHARSET_NAME_cp852, MYSQL_CHARSET_NAME_cp866, MYSQL_CHARSET_NAME_cp932, MYSQL_CHARSET_NAME_dec8, MYSQL_CHARSET_NAME_eucjpms, MYSQL_CHARSET_NAME_euckr, MYSQL_CHARSET_NAME_gb18030, MYSQL_CHARSET_NAME_gb2312, MYSQL_CHARSET_NAME_gbk, MYSQL_CHARSET_NAME_geostd8, MYSQL_CHARSET_NAME_greek, MYSQL_CHARSET_NAME_hebrew, MYSQL_CHARSET_NAME_hp8, MYSQL_CHARSET_NAME_keybcs2, MYSQL_CHARSET_NAME_koi8r, MYSQL_CHARSET_NAME_koi8u, MYSQL_CHARSET_NAME_latin1, MYSQL_CHARSET_NAME_latin2, MYSQL_CHARSET_NAME_latin5, MYSQL_CHARSET_NAME_latin7, MYSQL_CHARSET_NAME_macce, MYSQL_CHARSET_NAME_macroman, MYSQL_CHARSET_NAME_sjis, MYSQL_CHARSET_NAME_swe7, MYSQL_CHARSET_NAME_tis620, MYSQL_CHARSET_NAME_ucs2, MYSQL_CHARSET_NAME_ujis, MYSQL_CHARSET_NAME_utf16, MYSQL_CHARSET_NAME_utf16le, MYSQL_CHARSET_NAME_utf32, MYSQL_CHARSET_NAME_utf8, MYSQL_CHARSET_NAME_utf8mb3, MYSQL_CHARSET_NAME_utf8mb4, MYSQL_COLLATION_INDEX_binary, MYSQL_COLLATION_INDEX_utf8mb4_0900_ai_ci, MYSQL_COLLATION_INDEX_utf8mb4_general_ciCHARACTER_SET_CLIENT, CHARACTER_SET_CONNECTION, CHARACTER_SET_RESULTS, COLLATION_CONNECTION| Constructor and Description |
|---|
NativeCharsetSettings(NativeSession sess) |
| Modifier and Type | Method and Description |
|---|---|
private void |
buildCollationMapping()
Builds the map needed for 4.1.0 and newer servers that maps field-level
charset/collation info to a java character encoding name.
|
private boolean |
characterSetNamesMatches(java.lang.String mysqlEncodingName) |
private void |
checkForCharsetMismatch()
Determines if the connection charset is the same as the platform charset
|
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() |
java.lang.Integer |
getCollationIndexForCollationName(java.lang.String collationName) |
int |
getCollationIndexForJavaEncoding(java.lang.String javaEncoding,
ServerVersion version) |
int |
getCollationIndexForMysqlCharsetName(java.lang.String charsetName) |
java.lang.String |
getCollationNameForCollationIndex(java.lang.Integer collationIndex) |
private NativeMessageBuilder |
getCommandBuilder() |
java.lang.String |
getErrorMessageEncoding() |
java.lang.String |
getJavaEncodingForCollationIndex(int collationIndex) |
java.lang.String |
getJavaEncodingForCollationIndex(java.lang.Integer collationIndex,
java.lang.String fallBackJavaEncoding) |
java.lang.String |
getJavaEncodingForMysqlCharset(java.lang.String mysqlCharsetName) |
java.lang.String |
getJavaEncodingForMysqlCharset(java.lang.String mysqlCharsetName,
java.lang.String javaEncoding) |
int |
getMaxBytesPerChar(java.lang.Integer charsetIndex,
java.lang.String javaCharsetName) |
int |
getMaxBytesPerChar(java.lang.String javaCharsetName) |
int |
getMetadataCollationIndex() |
java.lang.String |
getMetadataEncoding() |
java.lang.String |
getMysqlCharsetForJavaEncoding(java.lang.String javaEncoding,
ServerVersion version) |
java.lang.String |
getMysqlCharsetNameForCollationIndex(java.lang.Integer collationIndex) |
java.lang.String |
getPasswordCharacterEncoding() |
boolean |
getRequiresEscapingEncoder() |
java.lang.String |
getServerDefaultCharset()
Get the server's default character set name according to collation index from server greeting,
or value of 'character_set_server' variable if there is no mapping for that index
|
boolean |
isImpermissibleCollation(int collationIndex) |
boolean |
isMultibyteCharset(java.lang.String javaEncodingName) |
private void |
tryAndFixEncoding(RuntimeProperty<java.lang.String> encodingProperty,
boolean replaceImpermissibleEncodings)
Attempt to use the encoding, and bail out if it can't be used.
|
getStaticCollationIndexForCollationName, getStaticCollationIndexForJavaEncoding, getStaticCollationIndexForMysqlCharsetName, getStaticCollationNameForCollationIndex, getStaticJavaEncodingForCollationIndex, getStaticJavaEncodingForCollationIndex, getStaticJavaEncodingForMysqlCharset, getStaticJavaEncodingForMysqlCharset, getStaticMblen, getStaticMysqlCharsetAliasesByName, getStaticMysqlCharsetByName, getStaticMysqlCharsetForJavaEncoding, getStaticMysqlCharsetNameForCollationIndex, isStaticImpermissibleCollation, isStaticMultibyteCharsetprivate NativeSession session
private ServerSession serverSession
public java.util.Map<java.lang.Integer,java.lang.String> collationIndexToCollationName
public java.util.Map<java.lang.String,java.lang.Integer> collationNameToCollationIndex
public java.util.Map<java.lang.Integer,java.lang.String> collationIndexToCharsetName
public java.util.Map<java.lang.String,java.lang.Integer> charsetNameToMblen
public java.util.Map<java.lang.String,java.lang.String> charsetNameToJavaEncoding
public java.util.Map<java.lang.String,java.lang.Integer> charsetNameToCollationIndex
public java.util.Map<java.lang.String,java.lang.String> javaEncodingUcToCharsetName
public java.util.Set<java.lang.String> multibyteEncodings
private java.lang.Integer sessionCollationIndex
private java.lang.String metadataEncoding
private int metadataCollationIndex
private java.lang.String errorMessageEncoding
protected RuntimeProperty<java.lang.String> characterEncoding
protected RuntimeProperty<java.lang.String> passwordCharacterEncoding
protected RuntimeProperty<java.lang.String> characterSetResults
protected RuntimeProperty<java.lang.String> connectionCollation
protected RuntimeProperty<java.lang.Boolean> cacheServerConfiguration
private boolean requiresEscapingEncoder
private NativeMessageBuilder commandBuilder
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.String>> customCollationIndexToCollationNameByUrl
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> customCollationNameToCollationIndexByUrl
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.String>> customCollationIndexToCharsetNameByUrl
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> customCharsetNameToMblenByUrl
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> customCharsetNameToJavaEncodingByUrl
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Integer>> customCharsetNameToCollationIndexByUrl
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> customJavaEncodingUcToCharsetNameByUrl
private static final java.util.Map<java.lang.String,java.util.Set<java.lang.String>> customMultibyteEncodingsByUrl
private boolean platformDbCharsetMatches
public NativeCharsetSettings(NativeSession sess)
private NativeMessageBuilder getCommandBuilder()
private void checkForCharsetMismatch()
public boolean doesPlatformDbCharsetMatches()
doesPlatformDbCharsetMatches in interface CharsetSettingsprivate void tryAndFixEncoding(RuntimeProperty<java.lang.String> encodingProperty, boolean replaceImpermissibleEncodings)
encodingProperty - connection property containing the Java encoding to tryreplaceImpermissibleEncodings - The character_set_client system variable cannot be set to ucs2, utf16, utf16le, utf32 charsets. If "true" the corresponding connection
property value will be replaced with "UTF-8"public int configurePreHandshake(boolean reset)
CharsetSettingsChoose 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 CharsetSettings.configurePostHandshake(boolean).
It also means that collation index should be set according to:
Since Protocol::HandshakeV10 and Protocol::HandshakeResponse41 has 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.
configurePreHandshake in interface CharsetSettingsreset - reset the charsets configuration; needed for changeUser call.public void configurePostHandshake(boolean dontCheckServerMatch)
CharsetSettingsCharsetSettings.configurePreHandshake(boolean) and sent in the Protocol::HandshakeV10 packet.
Here Connector/J alters these server variables if needed.configurePostHandshake in interface CharsetSettingsdontCheckServerMatch - if true then send the SET NAMES query even if server charset already matches the new value; needed for changeUser call.private boolean characterSetNamesMatches(java.lang.String mysqlEncodingName)
public java.lang.String getServerDefaultCharset()
public java.lang.String getErrorMessageEncoding()
getErrorMessageEncoding in interface CharsetSettingspublic java.lang.String getMetadataEncoding()
getMetadataEncoding in interface CharsetSettingspublic int getMetadataCollationIndex()
getMetadataCollationIndex in interface CharsetSettingspublic boolean getRequiresEscapingEncoder()
getRequiresEscapingEncoder in interface CharsetSettingspublic java.lang.String getPasswordCharacterEncoding()
getPasswordCharacterEncoding in interface CharsetSettingsprivate void buildCollationMapping()
public java.lang.Integer getCollationIndexForCollationName(java.lang.String collationName)
getCollationIndexForCollationName in interface CharsetSettingspublic java.lang.String getCollationNameForCollationIndex(java.lang.Integer collationIndex)
getCollationNameForCollationIndex in interface CharsetSettingspublic java.lang.String getMysqlCharsetNameForCollationIndex(java.lang.Integer collationIndex)
getMysqlCharsetNameForCollationIndex in interface CharsetSettingspublic java.lang.String getJavaEncodingForCollationIndex(int collationIndex)
getJavaEncodingForCollationIndex in interface CharsetSettingspublic java.lang.String getJavaEncodingForCollationIndex(java.lang.Integer collationIndex,
java.lang.String fallBackJavaEncoding)
public int getCollationIndexForJavaEncoding(java.lang.String javaEncoding,
ServerVersion version)
getCollationIndexForJavaEncoding in interface CharsetSettingspublic int getCollationIndexForMysqlCharsetName(java.lang.String charsetName)
getCollationIndexForMysqlCharsetName in interface CharsetSettingspublic java.lang.String getJavaEncodingForMysqlCharset(java.lang.String mysqlCharsetName)
getJavaEncodingForMysqlCharset in interface CharsetSettingspublic java.lang.String getJavaEncodingForMysqlCharset(java.lang.String mysqlCharsetName,
java.lang.String javaEncoding)
public java.lang.String getMysqlCharsetForJavaEncoding(java.lang.String javaEncoding,
ServerVersion version)
getMysqlCharsetForJavaEncoding in interface CharsetSettingspublic boolean isImpermissibleCollation(int collationIndex)
public boolean isMultibyteCharset(java.lang.String javaEncodingName)
isMultibyteCharset in interface CharsetSettingspublic int getMaxBytesPerChar(java.lang.String javaCharsetName)
getMaxBytesPerChar in interface CharsetSettingspublic int getMaxBytesPerChar(java.lang.Integer charsetIndex,
java.lang.String javaCharsetName)
getMaxBytesPerChar in interface CharsetSettings