Hi Bryan,
Thanks for the help and it now works.
>>I think this is DERBY-1938 (https://issues.apache.org/jira/browse/DERBY-1938).
Yes it is. 
 I understand the change you did.
Though we cast null into integer it remains as the same and it just help to pass from,
rs = st.executeQuery("values (3, cast (null as int))"); 
which does not allow null in the values.
But after we cast, it proceed as a null object(not null Integer) and when execution time it gave the NullPointerException. We cannot directly cast the null into Integer ((INTEGER)rs.getObject(i)). But we can do it by give the data type as integer,
pSt.setObject(i, rs.getObject(i), Types.INTEGER);
Am I correct in understanding?