简体   繁体   中英

Java Unknown char found on database

I'm creating a program that connects java to access database but I found some problem after inserting some string in the table.

I found this character: Â on every record that has "-" on it.

Example Data:

 A Sample Input -Data

When I try to check the database, I found this:

A Sample Input Â-Data

I don't know where did I get that character.

Im sure there is nothing wrong with my code, I just don't know why there is unknown char after inserting it on database.

The encoding used by Java and the encoding used by your database don't match up. The referenced SO article (in the comments above) seems appropriate, since Java uses Unicode and Access most likely does not (it probably uses CP-1252 or ISO-8859-1).

You haven't mentioned what library you're using to access the database. You should see if there's an option that allows you to specify the encoding. If not, then you may have to do the conversion yourself. Here's one example of how to do this using Java's CharsetEncoder .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM