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

  • Home
  • SEARCH
  • 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 9214797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:03:14+00:00 2026-06-18T02:03:14+00:00

Using a prepared statement I am trying to store Russian characters in a field

  • 0

Using a prepared statement I am trying to store Russian characters in a field on a particular tables. The table and field is using the utf8 character set and utf8_bin collation.

If I manually run an insert via an IDE or command line, the string saves as expected.

INSERT INTO utf8Table VALUES('Анатолий Солоницын');

I am then able to query that table and can get back the expected String as well.

The Connection is setup through a resource in tomcat’s context.xml file with the following config:

<Resource 
    name="jdbc/DoolliDB"  
        auth="Container"   
        type="javax.sql.DataSource"   
        driverClassName="com.mysql.jdbc.Driver"
        useUnicode="true"
        characterEncoding="UTF8"
        ....
</Resource>

As I said, I am able to read the string/characters just fine, so I assume that both the table and the connection settings are set properly.

I am using a PreparedStatement/CallableStatement in the following way:

CallableStatement callableStmt = __mySqlConnector.getConnection().prepareCall("INSERT INTO utf8Table VALUES(?)");

callableStmt.setString(1, "Анатолий Солоницын");

callableStmt.executeUpdate();

Instead of Анатолий Солоницын, what is getting inserted into the database is: ???????? ?????????

Also note that “normal” utf-8 strings, such as über, are getting saved
properly.

Both

System.getProperty("file.encoding") 

and

java.nio.charset.Charset.defaultCharset().name() 

are also both returning UTF-8.

Any help is appreciated. Thanks

  • 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-18T02:03:15+00:00Added an answer on June 18, 2026 at 2:03 am

    You need to define the connection encoding in the database url, not in the attribute.

    <Resource 
        name="jdbc/DoolliDB"  
            auth="Container"   
            type="javax.sql.DataSource"   
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/dbName?characterEncoding=UTF-8"
            ...
    </Resource>
    

    Please see http://dev.mysql.com/doc/refman/4.1/en/connector-j-reference-charsets.html

    Warning Do not issue the query ‘set names’ with Connector/J, as the
    driver will not detect that the character set has changed, and will
    continue to use the character set detected during the initial
    connection setup.

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

Sidebar

Related Questions

I am trying to implement an update statement using a prepared statement in a
I am trying to insert into Oracle Database using JDBC prepared statement. Below is
I'm trying build a conditions array to be using in a prepared statement: Cars.find(:all,
I am trying to use a prepared statement that deletes from two (temporary) tables:
Hi I am trying insert data into the database using prepared statement but I
I'm trying to execute a prepared statement using PDO however I keep getting an
I am trying to select from a mySQL table using prepared statements. The select
I am using mysqli prepared statments and I am trying to write a prepared
I am using following prepared statement : Class.forName(com.mysql.jdbc.Driver); con=DriverManager.getConnection(jdbc:mysql://localhost:3306/mysql,root,root); String query=select ename from ?
I am using prepared statements to store, retrieve and update data to or from

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.