or you can do this..

String name = request.getParameter("name");
String query = select * from description where name like=?;
PreparedStatement pStmt = dbConnection.prepareStatement(query);
pStmt.setString(1,name);
ResultSet rs = pStmt.executeQuery();

This way you don't have to bother about single quotes (PreparedStatement
will take care it)and also you don't have to write request.getParameter
wherever you need to access that parameter, instread just use variable
'name'.

Nishit
-----Original Message-----
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 17, 2001 4:27 PM
To: [EMAIL PROTECTED]
Subject: Re: jdbc taglib question ?????


Sufi,
You need single quotes around the string in your like clause.
select * from description where name like '<%= request.getParameter("name")
%>'

If that doesn't work you might have to do
select * from description where name like <%= "'" +
request.getParameter("name") + "'" %>


-Richard

-----Original Message-----
From: sufi malak [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 17, 2001 1:16 PM
To: [EMAIL PROTECTED]
Subject: jdbc taglib question ?????


could you please tell me what's wrong in this line:
select * from description where name like <%= request.getParameter("name")
%>


the file is like this :
..........
<%@ taglib uri="http://jakarta.apache.org/taglibs/jdbc" prefix="sql" %>

<% String name = request.getParameter("name"); %>
<% out.println(" The name is >>>>>:" + name); %>

<sql:connection id="conn1">
  <sql:url>jdbc:mysql://localhost/test</sql:url>
  <sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
</sql:connection>

<sql:preparedStatement id="stmt2" conn="conn1">
  <sql:query>
    select * from description where name like <%=
request.getParameter("name") %>
  </sql:query>
  <sql:resultSet id="rset1">
   <pg:item>
      <sql:getColumn position="1"/><br>
          <sql:getColumn position="2"/><br>
..............
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to