0

我很难弄清楚这一点......我想在第一行显示错误,例如在这个站点上没有找到结果时,当我输入随机单词时,搜索栏在桌子上没有......表格将显示错误并保留标题名称...

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

    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());
    }
4

0 回答 0