This week's book giveaways are in the Cloud/Virtualization and Go forums.
We're giving away four copies each of Cloud Native Transformation: Practical Patterns for Innovation and The Go Workshop and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

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: 67334
170
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!
 
Run away! Run away! Here, take this tiny ad with you:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!