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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:23:54+00:00 2026-05-18T05:23:54+00:00

I have a little problem, I am building a database from CSV files using

  • 0

I have a little problem, I am building a database from CSV files using a Java application connected to the mySQL database.

CSV is ISO-8859-1 encoded.
It is read via a buffered file reader and parsed with String methods.
Then the strings are introduced to mySQL via JDBC driver.

Problem is: accents (this is a french application) are lost in the transfer. In the mySQL database, they are in an unidentified format which is not UTF-8 neither Latin-1…

My hypothesis is that the Strings are encoded weirdly and keep this encoding when reinserted. How can-I enforce the charset for an INSERT statement in Java?

  • 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-18T05:23:54+00:00Added an answer on May 18, 2026 at 5:23 am

    You need to ensure that you read the CSV using InputStreamReader with the proper charset (which is the one of the file itself, which is in this particular case thus ISO-8859-1).

    BufferedReader reader = new BufferedReader(new InputStreamReader(input, "ISO-8859-1"));
    

    You also need to ensure that the JDBC connection string contains a characterEncoding parameter with the proper charset (which is the one the table is been created with, which you have yet to figure out on the MySQL database). If it appears to be an Unicode charset, then you need to add the parameter useUnicode=true as well.

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

    Your next question shall probably be How do I determine which charset my DB table is using?. You can do this using the SHOW command. It’ll contain information about the charset.

    SHOW CREATE DATABASE dbname; -- shows CREATE DATABASE statement.
    SHOW CREATE TABLE dbname.tblname; -- shows CREATE TABLE statement.
    

    That said, unrelated to the problem, are you aware that MySQL offers builtin CSV import facilities and that you thus don’t necessarily need Java/JDBC for this? Checkout the LOAD DATA INFILE command. You can specify the CSV file’s charset as command argument and MySQL will worry about the correct conversion itself.

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

Sidebar

Related Questions

I'm building my own advertisement platform, and I have a little problem. How can
I am building an application at work and need some advice. I have a
I have an application with multiple activities. In the main class I open a
I'm am designing my database/domain for an eCommerce application and I'm having a hard
First a little background. I am building a mobile app for a client, this
Again, asking MVC noob questions. Forgive my lack of experience. I have a situation
Crystal Reports 11 (craxdrt.dll 11.5.7.1048) Windows 7 I'm using Crystal Reports to export to
Nowadays i'm struggling with something i didn't experience maybe 5 years ago, and i
I am new to both Python (and django) - but not to programming. I

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.