Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not make sense to default MySQL character set and collation properties on connection URL #1294

Closed
tazmaniax opened this issue Feb 10, 2019 · 3 comments
Labels
Milestone

Comments

@tazmaniax
Copy link
Collaborator

Play Version (1.5.x / etc)

1.5.2

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

MacOS 10.14.4

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

Library Dependencies

Connector/J v5.1.47

Behaviour

Play currently adds the following default parameters to the connection URL:

  • useUnicode=yes
  • characterEncoding=UTF-8
  • connectionCollation=utf8_general_ci

The Connector/J 5.1 documentation on charsets does not recommend these properties are set instead preferring...

The character encoding between client and server is automatically detected upon connection (provided that the Connector/J connection properties characterEncoding and connectionCollation are not set).

As well if the server collation is not set to "utf8_general_ci" and that collation is not expected then unexpected results might occur.

In addition the documentation for useUnicode states that...

Should only be used when the driver can't determine the character set mapping, or you are trying to 'force' the driver to use a character set that MySQL either doesn't natively support.

I suggest these defaults are removed to allow the client to freely auto-detect the character set and collation from the server and avoid setting potentially unexpected and undesirable defaults.

@tazmaniax
Copy link
Collaborator Author

As a follow up, these current defaults actually stops utfmb4 from being used even with a properly configured MySQL v5.7 and the latest Connector/J version.

@sbeigel
Copy link
Contributor

sbeigel commented Feb 11, 2019

I can confirm that utf8mb4 works without these settings! Adding the following parameters to the connection URL can be a workaround (as they override the values in DBPlugin) until play's default config is changed/removed :

useUnicode=&characterEncoding=&connectionCollation=

xael-fry added a commit that referenced this issue Mar 12, 2019
…t_defaults

#1294 Remove MySQL connection charset property defaults
@xael-fry xael-fry added this to the 1.5.3 milestone Mar 12, 2019
@mohsen0
Copy link

mohsen0 commented May 30, 2022

I can confirm that utf8mb4 works without these settings! Adding the following parameters to the connection URL can be a workaround (as they override the values in DBPlugin) until play's default config is changed/removed :

useUnicode=&characterEncoding=&connectionCollation=

it did not work for me.

Can't start in PROD mode with errors

Database error
A database error occurred : Cannot connected to the database[default], Unsupported character encoding ''
 / play.exceptions.DatabaseException / Cannot connected to the database[default], Unsupported character encoding ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants