javasqljdbctemplate

Handling column null value in JdbcTemplate


I am using JdbcTemplate to get result of an query. Some of the columns can have null value in the DB table. But I am getting conversion exception complaining null can not be convert to long type.

How I can tell spring to put null in variable if it find null in the column?

I have data type as Long type.


Solution

  • Going to post this as an answer, in case someone else has the same issue and doesn't read the comments (and so this question comes up as having an answer in search results).

    The issue was that long was being used instead of Long. As longs cannot be null, it couldn't convert any nulls found in the database.