0

I am getting issue while persisting some strings with special characters, For eg:Livaković. In database it's getting saved as Livakovi?. My Jdbc string is as follows:

jdbc:mysql://localhost:3306/MyDb?autoReconnect=true&useUnicode=true&connectionCollation=utf8_general_ci&characterSetResults=utf8&useSSL=false

My DB Character Set is as follows:-

DB Character Set

Mysql Version is 5.6.

I am already using useUnicode=true and characterSetResults=utf8 in jdbc connection string but still special characters are not getting correctly in DB.

below is the result of show create-

CREATE TABLE `table_name` (
`id` varchar(64) NOT NULL,
 `name` varchar(64) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Can anyone suggest ?

Thanks,

Manish
  • 1,274
  • 3
  • 22
  • 59
  • 2
    Why are you mixing encodings like that? – Kayaman Aug 23 '18 at 12:43
  • as Kayaman mentioned, you have to make sure that your character set for the database can support those characters as well. `character_set_connection` only defines how the characters are transmitted, `character_set_database` says how they are stored. Maybe the answer GUIDO gave me on a similar quesion might help you: https://stackoverflow.com/a/26285517/896249 – GameDroids Aug 23 '18 at 12:49
  • Try using `useUnicode=true&characterEncoding=utf8` together. Many other answers specify them both. – Gord Thompson Aug 23 '18 at 13:55
  • 1
    Also [edit] your question to show the result from `SHOW CREATE TABLE table_name` – Gord Thompson Aug 23 '18 at 14:00
  • @Kayaman didn't get you ? – Manish Aug 23 '18 at 14:17
  • @GordThompson updated the post with SHOW CREATE TABLE table_name. – Manish Aug 24 '18 at 05:41

1 Answers1

0

That's one of several things to check.

See question marks , in particular

  • Are the bytes to be stored encoded utf8/utf8mb4?
  • Is the column in the table is CHARACTER SET utf8 (or utf8mb4). (Use SHOW CREATE TABLE.)

More Java/JDBC notes:

Add ?useUnicode=yes&characterEncoding=UTF-8 to the JDBC URL (you currently have characterSetResults)

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>

compileJava.options.encoding = 'UTF-8'
<form method="post" action="/your/url/" accept-charset="UTF-8">
Rick James
  • 135,179
  • 13
  • 127
  • 222