Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

checking nulls in recordset result

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-04-17 01:24:28.0Z
Victor DeLima Posted on 1997-04-12 19:21:20.0Z
Message-ID: <334FE0AF.6AB3@pcnet.com>
Date: Sat, 12 Apr 1997 15:21:20 -0400
From: Victor DeLima <vdelima@pcnet.com>
Reply-To: vdelima@pcnet.com
X-Mailer: Mozilla 3.01Gold (Win95; I)
MIME-Version: 1.0
Subject: checking nulls in recordset result
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 5
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:1026
Article PK: 252775

I have been trying to find a way to check a column to see if it is null.
But as soon as you access it you get an exception.. any ideas

ResultSet.getString(#)


Joseph White Posted on 1997-04-17 01:24:28.0Z
Message-ID: <33557BC9.D5BE2B96@rwd.com>
Date: Wed, 16 Apr 1997 21:24:28 -0400
From: Joseph White <jwhite@rwd.com>
Reply-To: jawhite@ibm.net
Organization: RWD Technologies, Inc.
X-Mailer: Mozilla 4.0b3 [en] (WinNT; I)
MIME-Version: 1.0
To: vdelima@pcnet.com
Subject: Re: checking nulls in recordset result
X-Priority: 3 (Normal)
References: <334FE0AF.6AB3@pcnet.com>
Content-Type: text/plain; charset=iso-8859-1
Newsgroups: sybase.public.jdbcconnect
Lines: 16
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:982
Article PK: 252734


Victor DeLima wrote:

> I have been trying to find a way to check a column to see if it is
> null.
> But as soon as you access it you get an exception.. any ideas
>
> ResultSet.getString(#)

Yes, the JDBC documentation describes how to deal with this. In
particular, you should "try" the getString and catch an exception. In
the exception handling you can check to see if the exception was caused
because the column was null.
... roughly use:
try
{
x = resultSet.getString(#)
}
catch
{
if (resultSet.wasNull()) x = null;
else ... handle exceptions>
}

Regards,
Joe White