Java - 没有找到结果时第一行的表显示错误

时间:2013-09-23 22:37:02

标签: java mysql sql jtable

我很难解决这个问题...我希望在第一行显示错误时,如果没有找到结果,例如 SITE 当我输入时有搜索栏表中没有任何随机单词...表格将显示错误并保留标题名称...

到目前为止这是我的代码......

    String tempSearchValue = searchStudent.getText().trim();
    boolean empty = true;
    sql = "SELECT student_id as 'Student ID',"
            + "concat(lastname, '  ,  ', firstname, ' ', middlename) as 'Name'"
            + "FROM user "
            + "WHERE CAST(student_id as CHAR) LIKE '%" + tempSearchValue + "%'";
    try {
        pst = conn.prepareStatement(sql);
        rs = pst.executeQuery();
        while(rs.next()) {
            table.setModel(DbUtils.resultSetToTableModel(rs));
            empty = false;
        }
        if(empty) {

        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.getMessage());
    }

0 个答案:

没有答案