我在数据库中创建了一个由telugu数据组成的表。当我试图通过在java中使用eclipse来检索telugu数据时,我正在使用矩形框。
代码:
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sloka?useUnicode=yes&characterEncoding=UTF-8", "root", "");
st = con.createStatement();
} catch (Exception e) {
System.out.print("error:" + e);
}
public void getData() {
try {
String query = "select * from eesavyasa ";
rs = st.executeQuery(query);
System.out.print("records from database");
while (rs.next()) {
String name1 = new String(rs.getBytes("firstcolumn"), "UTF-8");
String name2 = new String(rs.getBytes("secondcolumn"), "UTF-8");
String name3 = new String(rs.getBytes("thirdcolumn"), "UTF-8");
String name4 = new String(rs.getBytes("fourthcolumn"), "UTF-8");
System.out.println(name1);
System.out.println(name2);
System.out.println(name3);
System.out.println(name4);
}
} catch (Exception ex) {
System.out.print(ex);
}
}
我们已经为db,table使用了collation utf-8,但我们在矩形框中输出了输出 请尽快回复
答案 0 :(得分:0)
在连接到mysql
之后执行下面的sql后会修复它SET NAMES utf8