Or, for a more general solution, use a prepared statement with a host variable:
String searchString = "%'%";
PreparedStatement stmt = conn.prepareStatement(
"select * from table where name like ?");
stmt.setString(1, searchString);
ResultSet r = stmt.executeQuery();
Regards,
Bob
At 04:08 PM 5/12/00 -0400, you wrote:
>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
------------------------------------------------------------------------------------------
Bob Withers Do or do not, there is no try.
[EMAIL PROTECTED] Yoda.
http://www.ruffboy.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