Hi Elton,
Take a look at ResultSet.wasNull()
>From javadoc:
boolean wasNull()
throws SQLException
Reports whether the last column read had a value of SQL NULL. Note that
you must first call one of the getter methods on a column to try to read its
value and then call the method wasNull to see if the value read was SQL
NULL.
Returns:
true if the last column value read was SQL NULL and false otherwise
Throws:
SQLException - if a database access error occurs
Just check this after calling getDate().
-Simon
On 3/8/06 2:35 PM, "Elton Hughes" <email@hidden> wrote:
> Hello All,
>
>
> I have created a JDBC class that prints out a list of clients in our
> database. A part of the code looks like this:
>
> Date bgnDate = rs.getDate("BeginDate");
> String beginDate = formatter.format(bgnDate);
>
> Date estDate = rs.getDate("EstimatedEndDate");
> String estEndDate = formatter.format(estDate);
>
> Date eDate = rs.getDate("EndDate");
> String endDate = formatter.format(eDate);
>
> Unfortunately, it is valid to not have an EstimatedEndDate or
> EndDate. They can be null.
>
> How do I test to to see if something is there before trying to format
> a NULL, which will trigger a exception.
>
> Thanks,
>
> Elton
>
> =========================================================
> NOVA 505 W. Olive Ave. Suite 550
> Elton Hughes (IT) Sunnyvale CA 94086
> Phone: 408-730-7235 Fax: 408-730-7643
> ---------------------------------------------------------
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Java-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/java-dev/email@hidden
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden