需求描述:在页面输入英语音标,通过JAVA程序处理,存入MYSQL数据库。
问题描述:由于在插入DB前,音标显示为乱码,导致无法插入数据库。
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that c
orresponds to your MySQL server version for the right syntax to use near 't?kj?l?] ','[p?'t?kj?l?]','1','null')' at line其他说明:JAVA文件编码格式为utf-8,已经测试,中文可以正常显示。就是音标不行,音标中的音标字符显示为问号。
另外,写了个测试文件:
public class Test {
public static void main(String args[]) { System.out.println("particular [pɚ'tɪkjəlɚ]adj. 特别的;详细的;独有的;挑剔的n. 详细说明;个别项目");
}}
在CMD控制台测试:
D:\project\stefan\src>javac -encoding utf-8 com/stefan/learn/action/Test.javaD:\project\stefan\src>java com/stefan/learn/action/Test
particular 报错 英[p?'t?kj?l?] 美[p?'t?kj?l?]adj. 特别的;详细的;独有的;挑剔的n. 详细说明;个别项目
还是不能显示音标。尝试添加了音标所有的字体到系统中,还是不能解决。。
有没有高手知道怎么回事,谢谢非常感谢
问题描述:由于在插入DB前,音标显示为乱码,导致无法插入数据库。
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that c
orresponds to your MySQL server version for the right syntax to use near 't?kj?l?] ','[p?'t?kj?l?]','1','null')' at line其他说明:JAVA文件编码格式为utf-8,已经测试,中文可以正常显示。就是音标不行,音标中的音标字符显示为问号。
另外,写了个测试文件:
public class Test {
public static void main(String args[]) { System.out.println("particular [pɚ'tɪkjəlɚ]adj. 特别的;详细的;独有的;挑剔的n. 详细说明;个别项目");
}}
在CMD控制台测试:
D:\project\stefan\src>javac -encoding utf-8 com/stefan/learn/action/Test.javaD:\project\stefan\src>java com/stefan/learn/action/Test
particular 报错 英[p?'t?kj?l?] 美[p?'t?kj?l?]adj. 特别的;详细的;独有的;挑剔的n. 详细说明;个别项目
还是不能显示音标。尝试添加了音标所有的字体到系统中,还是不能解决。。
有没有高手知道怎么回事,谢谢非常感谢
需要显示utf-8字符,需要按照如下操作。运行cmd
然后在命令提示符下输入如下:
chcp 65001
然后再点击命令提示符窗口左上角的系统图标,选择系统菜单“属性”,设置字体为Lucida Console
然后再运行你的java命令应该可以显示。