Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cant find part of the String using JDBC?

 
Anuj Kalra
Greenhorn
Posts: 10
Java Oracle Tomcat Server
  • 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.
 
Krishnam Ch
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



 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65338
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Java Oracle Tomcat Server
  • 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
Java Oracle Tomcat Server
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic