Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7645355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:55:14+00:00 2026-05-31T09:55:14+00:00

For some strange reason I can’t seem to add UTF-8 data to my MySQL

  • 0

For some strange reason I can’t seem to add UTF-8 data to my MySQL database. When I enter a non-latin character, it’s stored as ?????. Everything else is stored fine. So for example, “this is an example®™” is stored fine, but “和英辞典” is stored as “????”.

The connection url is fine:

private DataSource getDB() throws PropertyVetoException {
    ComboPooledDataSource db = new ComboPooledDataSource();
    db.setDriverClass("com.mysql.jdbc.Driver");
    db.setJdbcUrl("jdbc:mysql://domain.com:3306/db?useUnicode=true&characterEncoding=UTF-8");
    db.setUser("...");
    db.setPassword("...");
    return db;
}

I’m using PreparedStatement as you would expect, I even tried entering “set names utf8” as someone suggested.

    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    try {
        conn = db.getConnection();

        stmt = conn.prepareStatement("set names utf8");
        stmt.execute();
        stmt = conn.prepareStatement("set character set utf8");
        stmt.execute();

                    ... set title...
        stmt = conn.prepareStatement("INSERT INTO Table (title) VALUES (?)");
        stmt.setString(1,title);

        stmt.execute();
    } catch (final SQLException e) {
    ...

The table itself seems to be fine.

Default Character Set: utf8
Default Collation: utf8_general_ci
...
Field title:
Type text
Character Set: utf8
Collation: utf8_unicode_ci

I tested it by entering in Unicode (“和英辞典” specifically) through a GUI editor and then selecting from the table — and it was returned just fine. So this seems to be an issue with JDBC.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:55:16+00:00Added an answer on May 31, 2026 at 9:55 am

    There is 2 points in the mysql server to check in order to correctly set the UTF-8 charset.

    Database Level

    This is obtained by creating it :

    CREATE DATABASE 'db' CHARACTER SET 'utf8';
    

    Table Level

    All of the tables need to be in UTF-8 also (which seems to be the case for you)

    CREATE TABLE  `Table1` (
        [...]
    ) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
    

    The important part being DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci

    Finally, if your code weren’t handling utf8 correctly, you could have forced your JVM to use utf8 encoding by changing the settings by on startup :

    java -Dfile.encoding=UTF-8 [...]
    

    or changing the environment variable

    "**JAVA_TOOLS_OPTIONS**" to -Dfile.encoding="UTF-8"
    

    or programmatically by using :

    System.setProperty("file.encoding" , "UTF-8");
    

    (this last one may not have the desire effect since the JVM caches value of default character encoding on startup)

    Hope that helped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some very strange reason, none of our texts views can receive bold, italic,
well for some strange reason IE gives me and InvalidAuthenticityToken error almost every time
I'm passing two strings between two activities and for some strange reason, the strings
For some strange, bizarre reason, my images in my website just will not display
I'm getting some strange, intermittent, data aborts (< 5% of the time) in some
I'm experiencing some strange behavior for which I can't find any documented knowledge. Here's
For some strange reason, UITableView resizes my cells to 320 width no matter how
For some strange reason, I need to call the operator->() method directly. For example:
I have a pretty basic question that confuses me for some strange reason. I
Something really weird is happening to my Rails app. For some strange reason, jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.