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 6871767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:50:42+00:00 2026-05-27T03:50:42+00:00

I am using Ajax call to insert Indian characters in MySQL database. I am

  • 0

I am using Ajax call to insert Indian characters in MySQL database. I am facing an UTF-8 encoding problem in between flow of my application.

When I am inserting the non-English characters directly by JDBC (not using an Ajax call), then it’s showing “????” in the database.

When I include

response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");

in my JSP file, then I receive the following in my database (question marks instead of non-English characters):

????????

When I do not include above lines it shows me junk character like this in database:

મà«?àª?પà«?ષà«?àª

Whereas the actual value is

મખપષ

So the actual problem lies in or after sending insert request to MySQL command in JSP through JDBC jdbc connector.

I have included following tags in all my JSP files to ensure character encoding:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

and

<meta http-equiv="Content-Type" content="text/html; charset=utf-8;charset=UTF-8">

I checked MySQL tables are Unicode enabled and I am able to enter correctly non English text through terminal.

How is this problem caused and how can I solve it?

Now, i am able to write using a insert statement only….but when i mix some queries and insert statement then… my application return me following error:
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation ‘=’
following are my database variables:

| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
| collation_connection     | utf8_general_ci            |
| collation_database       | utf8_general_ci            |
| collation_server         | utf8_general_ci            |
| completion_type          | 0                          |
| concurrent_insert        | 1                          |
| connect_timeout          | 10                         |
  • 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-27T03:50:42+00:00Added an answer on May 27, 2026 at 3:50 am

    When I am inserting the non-English characters directly by JDBC (not using an Ajax call), then it’s showing “????” in the database.

    This will only happen when the both sides are perfectly aware of the character encoding differences in each side. Any character which is not covered by the character encoding used on the other side will be replaced by a question mark ?. Otherwise you would have seen Mojibake.

    In this particular case, those sides are the Java side and the database side, with the JDBC driver as mediator. To fix this, you need to tell the JDBC driver what encoding those characters are in. You can do that by setting the useUnicode=true&characterEncoding=UTF-8 parameters in the JDBC connection URL.

    jdbc:mysql://localhost:3306/dbname?useUnicode=true&characterEncoding=UTF-8
    

    Then, depending on how you’re sending the parameters from the client to server, you possibly also need to fix the request encoding. Given the fact that you’re seeing Mojibake when you removes request.setCharacterEncoding("UTF-8"), you’re using POST. So that part is fine.

    For the case that, if you were using GET to send the parameters, you would need to configure URI encoding in the server side. It’s unclear what server you’re using, but in case of for example Tomcat, it’s a matter of editing the <Connector> entry in /conf/server.xml as follows:

    <Connector ... URIEncoding="UTF-8">
    

    See also:

    • Unicode – How to get the characters right?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using ajax call to insertmsg.php to insert a message. Now javascript isn't a
I'm using jQuery to make an Ajax call using an Http Post in ASP.NET
I am trying to perform a nested AJAX call using the following code. The
I have a method I want to call using AJAX in rails but I
I am loading feed-items into a ul using this jQuery .ajax() call, which I
I am trying to pass a dataString to to an ajax call using JQuery.
I am using an Ajax.ActionLink to call an Action in a Controller, nothing special
I'm using $.post() to call a servlet using Ajax and then using the resulting
I am using jQuery to make an AJAX call to a ruby method in
I'm using JQuery to make an Ajax call. I used a sniffer to catch

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.