This is how my connection is set:
Connection conn = DriverManager.getConnection(url + dbName + \"?useUnicode=true&characterEncoding=utf-8\", userName, password
Its mostly caused due to some unicode characters. In my case it was the Rupee currency symbol.
To quickly fix this, I had to spot the character causing this error. I copy pasted the entire text in a text editor like vi and replaced the troubling character with a text one.
If you are creating a new MySQL table, you can specify the charset of all columns upon creation, and that fixed the issue for me.
CREATE TABLE tablename (
<list-of-columns>
)
CHARSET SET utf8mb4 COLLATE utf8mb4_unicode_ci;
You can read more details: https://dev.mysql.com/doc/refman/8.0/en/charset-column.html
You need to set utf8mb4 in meta html and also in your server alter tabel and set collation to utf8mb4
I also had to drop and re-create all the database’s stored procedures (and functions too) in order that they execute within the new character set of utf8mb4.
Run:
SHOW PROCEDURE STATUS;
…to see which procedures have not been updated to the server’s new character_set_client, collation_connection and Database Collation values.
just do
ALTER TABLE `some_table`
CHARACTER SET = utf8 , COLLATE = utf8_general_ci ;
ALTER TABLE `some_table`
CHANGE COLUMN `description_with_latin_or_something` `description` TEXT CHARACTER SET 'utf8' NOT NULL ;
Droppping schema and recreating it with utf8mb4
character set solved my issue.