jdbc - MySQL SMALLINT column returns 0 in java.lang.Short when the value is null -


i've com across , haven't been able find proper documentation.

basically have in mysql table column used hold year value type of column smallint column can null, , whenever retrieve value (null) using method resultset.getshort("year"); 0 instead of expected null value.

the year value member of bean means use accessor methods, when use callablestatement object , set placeholders accordingly nullpointerexception know should expected there cases when need explicitly set value null such when year not supplied or user enters letters or string not "year"

is default behavior other wrapper classes primitives allow null values.

what right type mapping smallint or should change column int?

i don't know library (or java, matter), think found code here , took peek. seems getshort returns short, , never null, can use wasnull check if last retreived value null.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -