• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Cant find part of the String using JDBC?

 
Greenhorn
Posts: 10
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I have a database connected to my application.
My page has a search box where I can search items..

In the action JSP file, after getting a connection from the database, I take the value entered in the text box in a string

I am getting the results but only if I enter title in text box as it was entered in the database.

How do I get the query to search for even the part of the string. Like it is done on e-commerce websites.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Ajax for this kind of requirement. sample code to use Ajax



 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use SQL LIKE operator with a wildcard. Also, you need to think about UPPER vs lower case comparisons e.g. make sure you are comparing values in the same case.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The use of Ajax or not has nothing at all to do with this question.
 
Anuj Kalra
Greenhorn
Posts: 10
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chris webster wrote:Use SQL LIKE operator with a wildcard. Also, you need to think about UPPER vs lower case comparisons e.g. make sure you are comparing values in the same case.



Bingo!
I had the same thing in mind but what I was doing wrong was, as you said, NOT thinking about case.

Now thanks to you it works!

Thanks
Anuj

P.S Did you know that to convert your string to lower case, you have to use:

instead of

That was also the mistake i was making.
Gee! I guess we really do learn new things every day!
Once again thanks for your help! :beerjug:
 
Anuj Kalra
Greenhorn
Posts: 10
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Krishnam Ch wrote:You can use Ajax for this kind of requirement. sample code to use Ajax



Thanks man! Appreciate your help but I am kind of behind schedule for this and learning something new right now will cause more problems for me!

Thanks anyways!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic