1

I got an error of java.lang.NullPointerException when I try to display ORNumber to my textfield. There are 4 more fields in my database but I only want to display official_reciepts. Here is my code:

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);
    }
}                
Albert
  • 43
  • 6
  • Take a look at the stacktrace and find out which object reference is ``null``. We can't help you like this. – f1sh Oct 11 '16 at 09:10

0 Answers0