db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zorro <hz0...@gmail.com>
Subject Re: accessing records problem
Date Mon, 10 Feb 2014 09:25:48 GMT
Bob M schreef op 10-2-2014 10:19:
> Hi
>
> I am calling derby within a larger java program....................
>
> Step1: I allocate a database "Connection" object
> Step2: I allocate a "Statement" object in the connection
> Step 3: I execute a SQL SELECT query, the query result is returned in a
> "ResultSet" object
> so far so good (I update the latest database record, I add a new record and
> I delete the oldest record
> I then call a data mining program [Weka]
> I setup a few Weka models etc......
> I then wish to look at the last 100 records in my database, one at a time
> The code I have currently is as follows:-
> ***********************
> try {
> Statement s = null;
> ResultSet rs = null;
> rs = s.executeQuery ("SELECT".................);
> int k = 0
> while (k < 101) {
> rs.next();
> ...
> ...
> }
> k++;
> }
> }
> catch (Exception e)
> {
> myConsole.getOut().println(e);
> }
>
> I get the following error:-
> java.lang.NullPointerException
>
> do I need to do something further to read my 100 records?
>
> Bob M

Probably this is not where your program is crashing nevertheless you 
have this:
Statement s = null;
ResultSet rs = null;
rs = s.executeQuery ("SELECT".................);

since s = null it will throw a npe.

Regards,
Harm-Jan Zwinderman

http://Cebuned.svipr.nl/Cebuned.html



Mime
View raw message