I have a lot of raw data (objects of type SqlData) entering and trying to insert into Oracle using a user-defined type.
The problem is only for records that have some long attributes that are null. I get a NullPointer exception for these entries - since it is trying to call toString for a null object.
Is it possible to write null values ββfor a long column (in a SQLOutput stream)?
I know that this is possible by changing the type of String, but I cannot touch the PL / SQL function, as this is used in many places.
public classMyClass extends MyBaseType implements SQLData {
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeString(getSource());
stream.writeTimestamp(getDtm());
stream.writeString(getUniqueId());
stream.writeString(getType());
stream.writeLong(getResponseCode());
The last line throws a NullPointer exception if getResponseCode () is null.
Any idea how to handle this without changing the type (to String)?
,
private void writeNullPossibleNumber(SQLOutput stream, Integer intValue) throws SQLException {
if (intValue==null) {
stream.writeBigDecimal(null);
} else {
stream.writeInt(intValue);
}
}
.
:
http://docs.oracle.com/cd/A87860_01/doc/java.817/a81357/sampcod3.htm