1

So charset in my mysql db is utf-8. Also if I don't use useUnicode=true&characterEncoding=UTF-8 in the jdbc URL, then some characters goes as ?.

I want to know why to useUnicode=true&characterEncoding=UTF-8 in the jdbc URL when our charset is utf-8 in our db.

This is my table properties ->

ENGINE=InnoDB 
DEFAULT CHARSET=utf8
TABLE COLLATION=utf8_general_ci
royatirek
  • 2,437
  • 2
  • 20
  • 34

1 Answers1

1

MySQL has column character sets (with defaults per table and per database). It also has connection character sets, and they are not the same thing. In what character set is your SQL statement written? In what character set are results returned? That's why you choose a connection character set. The details are more complex than my summary. Read this. https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html

Servers have defaults for this. But it is good practice to set it in your client program; if you migrate to a production server with wrong defaults your program will still work.

O. Jones
  • 103,626
  • 17
  • 118
  • 172