extracting unicode text from mysql to java

2019-05-24 15:11发布

I have a table 'test' in my database with a column 'msg' that stores strings in various languages like English, Hindi, Telugu, etc. These strings are displayed properly in the database. But if i extract it into my java code and print it on the console using system.out.println , it shows ????????? instead of the actual string.

Is this because the font used in eclipse console does not support these scripts? If so, how can i change the font to something else?

2条回答
The star\"
2楼-- · 2019-05-24 15:23

You cannot print the UTF-8 characters on console with its default settings. Make sure the console you use to display the output is also encoded in UTF-8.

In Eclipse for example, you need to go to Run Configuration > Common -> Encoding -> Select UTF-8 from dropdown.

enter image description here

查看更多
萌系小妹纸
3楼-- · 2019-05-24 15:35

Try adding characterEncoding=UTF-8 parameter to the end of your JDBC connection URL. Even set the table and column character set to UTF-8. This article explains how to do that.

Also change the Eclipse console Output encoding using

Run Configuration > Common -> Encoding

查看更多
登录 后发表回答