“Incorrect string value” when trying to insert UTF-8 into MySQL via JDBC?

前端 未结 18 943
无人及你
无人及你 2020-11-22 07:51

This is how my connection is set:
Connection conn = DriverManager.getConnection(url + dbName + \"?useUnicode=true&characterEncoding=utf-8\", userName, password

18条回答
  •  失恋的感觉
    2020-11-22 07:53

    Hint: On AWS RDS you need a new Parameter Group for your MySQL DB with the params (instead of editing a my.cnf)

    • collation_connection: utf8mb4_unicode_ci
    • collation_database: utf8mb4_unicode_ci
    • collation_server: utf8mb4_unicode_ci
    • character_set_client: utf8mb4
    • character_set_connection: utf8mb4
    • character_set_database: utf8mb4
    • character_set_results: utf8mb4
    • character_set_server: utf8mb4

    Note: character_set_system stays "utf8"

    These SQL commands do NOT WORK PERMANENTLY - only in a session:

    set character_set_server = utf8mb4;
    set collation_server = utf8mb4_unicode_ci;
    

提交回复
热议问题