hi.
thaks for u cooperation to me.
my code is like this
if(action.equalsIgnoreCase("search"))
{
String searchKey=req.getParameter("searchfield");
String select = req.getParameter("select");
System.out.println("serch key is----> "+searchKey);
System.out.println("U r Selected is---->"+select);
con=DBconn();
PreparedStatement pst = null;
ResultSet rs;
ArrayList search= new ArrayList();;
try
{
if(select.equalsIgnoreCase("products"))
{
System.out.println("hi iam in products");
ArrayList list=new ArrayList();
String skey = "\'%"+searchKey+"%\'";
StringTokenizer
test = new StringTokenizer(skey);
while (test.hasMoreTokens()) {
System.out.println("Count tokens are--->"+test.countTokens());
System.out.println("tokens are--->"+test.nextToken());
}
StringBuffer sqlBuffer = new StringBuffer();
System.out.println("Search key is-->"+searchKey);
sqlBuffer.append(" select P.ECMSKU ITEM_ID, P.ECMLDS ITEM_TITLE, 'ESH' ITEM_TYPE");
sqlBuffer.append(" from ECMMST P");
sqlBuffer.append(" where");
sqlBuffer.append(" P.ECMSTS = 'A'");
sqlBuffer.append(" AND UPPER(P.ECMLDS) LIKE UPPER("+skey+")");
pst=con.prepareStatement(sqlBuffer.toString(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=pst.executeQuery();
while(rs.next())
{
int i=0;
System.out.println("ID id-->"+rs.getInt(1));
System.out.println("Product title-->"+rs.getString(2));
System.out.println("product type is-->"+rs.getString(3));
searchBean bean = new searchBean();
bean.setId(rs.getInt(1));
bean.setTitle(rs.getString(2));
bean.setType(rs.getString(3));
search.add(bean);
req.setAttribute("products",search);
}
----------------------------------
If i Pass search key is: "yamaha piano".
Actually "yamaha piano" record is not there in data base.
so no record is displaying.
But want to get result like.
If any records avalible either starting with yamaha or piano.
my problem how to divide tokens for a given string(sentence). and how to pass that tokens are Query String.
plz tell me.
I am wating u r reply.