Hi,
I think the code should be :-
for (int i=1; i<=numCols; i++) {
String s = rs.getString(i);
if ( !rs.wasNull())
out.println("<td>" + rs.getObject(i).toString()+"</td>");
else
out.println("<td>NULL</td>");
}
Hope this helps,
Paul
> -----Original Message-----
> From: Deepak Patil [mailto:[EMAIL PROTECTED]]
> Sent: 01 October 1999 13:22
> To: [EMAIL PROTECTED]
> Subject: Re: how to check whether a column value is null in a database
> tab le
>
>
>
>
> Here is the code I am using but it gives SQLException : No Data Found
>
> for (int i=1; i<=numCols; i++) {
> String s = rs.getString(i);
> if ( s != null)
> out.println("<td>" + rs.getObject(i).toString()+"</td>");
> else
> out.println("<td>NULL</td>");
> }
>
> I am using MSSQL-server and jsdk 2.1
> What's wrong in this ?
>
> Deepak
>
>
> >From: "Sonal Patni (CTS)" <[EMAIL PROTECTED]>
> >Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> > Servlet API Technology." <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Re: how to check whether a column value is null in a
> database tab
> > le
> >Date: Fri, 1 Oct 1999 15:14:17 +0530
> >
> >probably what u r doing is str.equals(null) which is bound to give a null
> >pointer exception
> >
> >instead of that should do (str==null)
> >
> >
> >-----Original Message-----
> >From: Deepak Patil [mailto:[EMAIL PROTECTED]]
> >Sent: Friday, October 01, 1999 1:09 AM
> >To: [EMAIL PROTECTED]
> >Subject: how to check whether a column value is null in a database table
> >
> >
> >Hi
> >I am using
> >rs.getString(1)
> >for getting a 1st columns value of a database table, I want to check
> >whether
> >the value is null or not, because if I use it without checking whether it
> >is
> >null or not it gives me a runtime NullPointerException....
> >
> >how can I check for nulity
> >
> >Deepak
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
> __________________________________________________________________
> _________
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html