Yes, this thread already is in the JDBC forum. One of the moderators here moved your post when he noticed it is indeed a JDBC related problem.
Did you actually find the stack trace in your logs? In this case, there will be not only the exception name (
NullPointerException), but also the line number on which the exception occurred. This would help tremendously to track down the problem. It is much more probable that the "JDBC solvers" will help you if you provide this information (see also
TellTheDetails).
In any case, take a closer look at this code fragment of yours:
There are several problems with it:
1) If any of these database fields is
NULL, you'll get a
NullPointerException, as you cannot use
toString() with nulls.
2) This code loops over all records returned by the query, overwriting the values in your variables in each go without actually using them. Only the values from the last record are kept in the variables and used by the later code. This is suspicious and even if it was a desired functionality, it should be done differently.
3) Though you close the resources (
rs,
stmt,
con), you don't do this in a
finally block, therefore they don't get closed when an exception occurs.