Well may be you won't have less ugly code, but at least it will be hidden ;-)
I think the easiest way it to use you own PreparedStatement class. So you can do any special treatment or workaround in a centralized and unique place.
----- Original Message -----
From: Peter Ondruška
To: Derby Discussion ; Tomcat Programmer
Sent: Thursday, July 21, 2011 12:45 AM
Subject: Re: nulls in prepared statement

Eclipselink or Hibernate might help if you want less ugly code.

Dne 20.7.2011 23:38 "Tomcat Programmer" <tcprogrammer@yahoo.com> napsal(a):
>> You must explicitly set value to null:
>> if (cobj.getPartNo()==null) pstmt.setNull(1, java.sql.Types.VARCHAR);
>> else pstmt.setString(1,cobj.getPartNo());
> Hi Peter, thanks for responding but I am aware of this as I indicated in my post. You realize how tedious this will be with any significant number of fields?  What I am asking about is if there is an alternate solution.  
> Thanks in advance, 
> TC