I am trying to save all the values of a defaulttablemodel to my sql database but whenever I put try to print the value on the last inserted row via table.valueAt(), it returns null.
try{
    System.out.print(table.getValueAt(5,0)); //<- this returns null even if the table.getRowCount() is 6
    for(int i=0; i<table.getRowCount();i++){
        if((Boolean)table.getValueAt(i,1)) val=1;
        else val=0; 
        //System.out.print(table.getValueAt(i, 0) +","+ val);
        String sql1 = "INSERT INTO HREmpListofCard (EmpID, CardNbr, Status, Remarks) VALUES ("
            +"'"+empID
            +"','"+table.getValueAt(i, 0).toString() 
            +"','"+val
            +"','"+table.getValueAt(i,2).toString()+"')";
        try {
            DBConnect.getConnection().createStatement().executeUpdate(sql1);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ListOfCardID.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(ListOfCardID.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}catch(Exception e){
    System.out.print("\nerror!");
}
 
     
    