Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL LIKE vs. Java indexOf()

843854May 18 2004 — edited May 19 2004
Hi,

Conditions:
--
1. User can search records in the database by entering up to 10 parameters.
2. One of parameters are Key Words to search in any of 10 columns in a table.
3. Java generates SQL query dynamically, depending on the number of actually provided parameters.

-- Option 1
Java program will generate 10 LIKE conditions to search each Key Word in 10 columns (20 LIKEs/2 keywords, and so on).

-- Option 2
Java program will not generate LIKE statements. Java will read records using less SQL conditions, and then filter objects by calling String.indexOf(Key Word) 10 times per Key Word (20 LIKEs/2 keywords, and so on).

Database: MySQL 3.xx.xx

What is better in your opinion?

Evgeny
Javadesk
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2004
Added on May 18 2004
5 comments
167 views