所选记录不会显示在textfield java中

时间:2016-10-11 09:07:42

标签: java database ms-access

当我尝试将ORNumber显示到我的文本字段时,我收到了java.lang.NullPointerException错误。我的数据库还有4个字段,但我只想显示official_reciepts。这是我的代码:

private void jtCrbMouseClicked(java.awt.event.MouseEvent evt) {                                   

    try {
        int row = jtCrb.getSelectedRow();
        String table_clicked = (jtCrb.getModel().getValueAt(row, 0).toString()); 

        ps = con.prepareStatement("SELECT * from Collection_Reports where official_reciepts = '" + table_clicked +"' ");
        rs = ps.executeQuery();

        while(rs.next()) {
            String add1 = rs.getString("official_reciepts");
            txtORnumber.setText(add1);
        }
    }
    catch (Exception e) {
        System.out.println("" + e);
    }
}                

0 个答案:

没有答案