【问题标题】:how can we see output without rectangular boxes我们怎样才能看到没有矩形框的输出
【发布时间】:2014-12-03 06:45:08
【问题描述】:

我在数据库中创建了一个包含泰卢固语数据的表。当我尝试在 java 中使用 eclipse 检索泰卢固语数据时,我得到了矩形框。

代码:

    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 使用了整理 utf-8,但我们在矩形框中得到了输出 请尽快回复

【问题讨论】:

  • 你的字体不支持 unicode 点...
  • 你能准确定义吗
  • 您要显示的字符在您使用的字体中不可用,请更改字体...

标签: java unicode


【解决方案1】:

连接mysql后执行下面的sql后会修复

SET NAMES utf8

【讨论】:

  • 你能准确定义吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-20
  • 2021-11-25
  • 1970-01-01
  • 2016-02-29
  • 2014-08-22
  • 1970-01-01
  • 2022-08-11
相关资源
最近更新 更多