db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zorro <hz0...@gmail.com>
Subject Re: selecting a particular record from a derby table
Date Fri, 14 Dec 2018 09:25:16 GMT
On 12/14/18 5:12 AM, Bob M wrote:
> Thanks Bryan
>
> I have rewritten the code as follows
> *********************************************
>   // if we have a candidate_ID to be validated, update Prototype record with
> Occurances
> if (Candidate_ID_to_be_validated > 0) {
>          fw.writetoFile(("we get to here - 1"), File_Name);
>          // update Occurances field in the similar Prototypes record by 1
>          psUpdate = conn.prepareStatement("UPDATE PROTOTYPES SET Occurances =
> Occurances + 1                 WHERE Prototype_ID = ?");
>          fw.writetoFile(("we get to here - 2"), File_Name);
>          ps.setInt(1,Candidate_ID_to_be_validated);
>          psUpdate.executeUpdate();
>          // commit the above transactions
>          conn.commit();
>          fw.writetoFile(("Updated Prototypes record with Occurances"),
> File_Name);
>          fw.writetoFile(("and Occurances is : - " + (Occurances + 1)),
> File_Name);
> ***********************************************************************
> Candidate_ID_to_be_validated = 3
> The last entry in the log file is "we get to here - 2"
>
> and I get a NullPointerException error - not exactly sure which line is
> creating this error
>
> Bob M


Shouldn't you use psUpdate.setInt(1,Candidate_ID_to_be_validated);

Harm-Jan Z


Mime
View raw message