Thanks to all:
This is way to do it. Escape ' with '.
I am sure it is DB2 way of doing things.
Best Regards
Gunjan
> ----------
> From: Boemio, Neil (CAP, FGI)[SMTP:[EMAIL PROTECTED]]
> Sent: Friday, May 12, 2000 4:45 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Database and Servlet
>
>
>
> -----Original Message-----
> From: Doshi, Gunjan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 12, 2000 4:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Database and Servlet
>
>
> Tried it:
> This is the result
> COM.ibm.db2.jdbc.app.DB2Exception: [IBM][CLI Driver][DB2] SQL0104N An
> unexpected token "%" was found following "". Expected tokens may include:
> "FOR WITH ORDER UNION EXCEPT OPTIMIZE ". SQLSTATE=42601
>
> > ----------
> > From: Laiwu Luo[SMTP:[EMAIL PROTECTED]]
> > Reply To: A mailing list for discussion about Sun Microsystem's Java
> > Servlet API Technology.
> > Sent: Friday, May 12, 2000 4:08 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Database and Servlet
> >
> > Put a blackslash (\) in front of the single quote (') should fix your
> > problem.
> > For you particular example,
> > the quer should look like: select * from name_table where name like
> > '%\'%'.
> >
> > -- Laiwu
> >
> > "Doshi, Gunjan" wrote:
> >
> > > Friends:
> > >
> > > My Servlet queries the DB2 database table. However some entries in the
> > > column have ' as its entries. I want to search for all of them
> > >
> > > Example: O' Peter. I am talking of the single quote ' in the name.
> > >
> > > So when I say select * from name_table where name like '%'%'
> > >
> > > It is wrong because single quotes because %'% is illegal within ' '.
> > How do
> > > I do it.
> > >
> > > Gunjan
> > >
> > >
> >
> __________________________________________________________________________
> > _
> > > 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
> >
> > --
> > Laiwu Luo
> > Global Crossing Telecommunications, Inc.
> > Systems & Product Development
> > Email: [EMAIL PROTECTED]
> > Phone: 248-647-6920 Ext. 4010
> >
> >
> __________________________________________________________________________
> > _
> > 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
>
___________________________________________________________________________
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