Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By lpt2007

Thread: mysql read/write slovenian/croatian characters in mysql database

  1. #1
    lpt2007 is offline Member
    Join Date
    Nov 2016
    Posts
    31
    Rep Power
    0

    Default mysql read/write slovenian/croatian characters in mysql database

    Problem storing some charcaters is mysql database?

    ŠĐČƎ ------> Š???Ž

    For ĐČĆ I get ? (question mark).

    I try to change mysql database charset utf-8 and I added "?useUnicode=true&characterEncode=UTF-8" in mysql connection. But not working.

  2. #2
    SurfMan's Avatar
    SurfMan is online now Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,722
    Rep Power
    6

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    Check the collation of the table. That's probably still Latin or something. Set it to "utf8" too.

    Second, what are you using to show the result? It could well be that the characters are stored properly, but your testing method can't display them.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  3. #3
    lpt2007 is offline Member
    Join Date
    Nov 2016
    Posts
    31
    Rep Power
    0

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    I change database charset to utf 8 but the result is still the same

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    5,847
    Rep Power
    10

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    I would recommend doing the following:

    1. Ensure that the characters are encoded correctly (you can do this by printing out their numerical value as integers).
    Then check against a table of values (the values may be in some other base like octal or hex).
    2. Then store them in the DB and read them back. Then compare to the original to ensure nothing is getting changed.

    If the above works you should focus on the display part.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    lpt2007 is offline Member
    Join Date
    Nov 2016
    Posts
    31
    Rep Power
    0

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    Quote Originally Posted by jim829 View Post
    I would recommend doing the following:

    1. Ensure that the characters are encoded correctly (you can do this by printing out their numerical value as integers).
    Then check against a table of values (the values may be in some other base like octal or hex).
    2. Then store them in the DB and read them back. Then compare to the original to ensure nothing is getting changed.

    If the above works you should focus on the display part.

    Regards,
    Jim
    How to do that?

  6. #6
    lpt2007 is offline Member
    Join Date
    Nov 2016
    Posts
    31
    Rep Power
    0

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    Š and Ž character are stored in database ok.

    Problem is only ČĆĐ they all stored in database as ???(question mark).

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,239
    Rep Power
    23

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    How have you checked that, though?

    With charset issues you need to ensure that the thing you are using to check the values is also set correctly, and has a font that can display them.
    For example, outputting to a text file and opening in Windows Notepad will result in ??? for lots of characters as Notepad has no font to handle them...that doesn't mean the value in the text file is wrong.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,239
    Rep Power
    23

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    As for checking the character values, if you are on Java 8 (and you should be) then you can use the chars() method of a String, and the forEach() on the returned Stream.
    This will allow you to output the values:
    Java Code:
            String test = "test";
            test.chars().forEach(c -> System.out.println(c));
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    lpt2007 is offline Member
    Join Date
    Nov 2016
    Posts
    31
    Rep Power
    0

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    Problem is solwed.

    I read database table status with mysql command "show table status" and then changed all tables character set to utf8_unicode_ci with command "alter table YOURtableNAME convert to character set utf8 collate utf8_unicode_ci"
    jim829 likes this.

  10. #10
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    5,847
    Rep Power
    10

    Default Re: mysql read/write slovenian/croatian characters in mysql database

    Great! I am certain someone will eventually benefit from your detective work.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 4
    Last Post: 10-29-2012, 06:46 PM
  2. write stuff from jTable to mySQL table
    By MonkeyMan in forum New To Java
    Replies: 1
    Last Post: 03-13-2012, 04:37 PM
  3. Replies: 4
    Last Post: 03-05-2012, 12:26 AM
  4. can't write my jdbc class to manipulate mysql
    By dilanka007 in forum New To Java
    Replies: 2
    Last Post: 01-03-2010, 11:10 PM
  5. Replies: 1
    Last Post: 08-07-2007, 05:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •