• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Query from oracle database for specific character

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...
please assist me:

I want to query a name called "hello_sbm_007" from a field.

I used this code:



The code should query word that contains "_SBM_" . It didn't worked for me.

Pleas help
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I don't see how the given information fits in each other and above all I also don't see how this is related to JSP.

Please elaborate your problem the smart way.
 
Albert Hopkins
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok..this is another example



you can see this line.

It queries "RDBMS" from the database. I want that the script queries any word contains any "R _ _ _ S" . The result will come out.

In SQL, I understand we can use ( select dataSourceType from data where dataSourceType like 'r_ _ _s') .

I hope this helps.

thank you
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Albert Hopkins wrote:
you can see this line.

It queries "RDBMS" from the database.


This doesn't query "RDBMS" from the database at all. It just compares the string "RDBMS" with the string value as referenced by 'dataSourceType'.

I want that the script queries any word contains any "R _ _ _ S" . The result will come out.

In SQL, I understand we can use ( select dataSourceType from data where dataSourceType like 'r_ _ _s') .

I hope this helps.

thank you

This is database specific. Consult its documentation. In MySQL you could do so, but then without spaces.

This has still nothing to do with JSP at all. If you were writing this code in a JSP file, you should immediately stop this and moving it into a real Java class. Scriptlets are a bad practice.
 
Albert Hopkins
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
Albert Hopkins
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok...

the script compares string

"RDBMS" using .equals

How if i don't want to use equals, because I want the script to compare without using the whole "RDBMS". Just compare "R....S" ??

Can you suggest??
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Check out this String.matches(). Create a regular expression something like "R[a-zA-Z]*S" this and match the result.

Note if you want to limit the charcters to 5, change it accordingly using Regex Pattern
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's sometimes very impressive how a question can be asked the bad way that it will be interpreted completely differently.

In the future please try to use the correct terminology and ask questions the smart way.
 
reply
    Bookmark Topic Watch Topic
  • New Topic