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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:13:47+00:00 2026-06-09T19:13:47+00:00

I have a small Java method that inserts short messages to a MySQL Database.

  • 0

I have a small Java method that inserts short messages to a MySQL Database.
the table’s default Collation is utf8_unicode_ci and the java code is:

private void insertMessageToDataBase(String lRoom, String lChatusername,
            String lMessage) {
        try {
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost/embeddedChat?" +
                "user=site_access&password=XXXXXXX");
            addMessageToDataBase = con.prepareStatement("INSERT INTO `" + lRoom + "` (username, message, action)" +
                    " VALUES (?,?,'message');");
            addMessageToDataBase.setString(1, lChatusername);
            addMessageToDataBase.setString(2, lMessage);
            addMessageToDataBase.executeUpdate();
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
    }

the problem is that when lMessage is in hebrew the result is a string of ‘??????’

BTW:
I don’t know if it helps but there is also a PHP script that sometimes write to another similar table in this database and it works fine.

  • 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-06-09T19:13:49+00:00Added an answer on June 9, 2026 at 7:13 pm

    Set UTF-8 in your code. See this;

        Connection con = DriverManager.getConnection("jdbc:mysql://localhost/embeddedChat?useUnicode=true&characterEncoding=utf8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where there is a small piece of Java code that
I have a method (the code below is a simplified version) that parses small
I have a small Java file interacting with a postgresql database, so I've downloaded
I have a small Java program that reads list of IPs from text file
I have a small java program that reads a file in, in eclipse i
I currently have a small text game I've written in Java that utilizes System.out.print();
I am trying to make some small additions to some old java code that
I have a small Java desktop app that uses Swing. There is a data
I have written a small webservice[Axis2/Java] which exposes a method public String Fill(String cacheName
I have a method that's about ten lines of code. I want to create

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.