This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
ive been implementing a basic search function which given a specified keyword searching a column in a database for records that contain the keyword. problem is the search is case sensitive and does not take into consideration that the keyword may be a substring.
for instance, forename = David will only return this record if you specify "David" "david, dav" does not work but i want it to. any advice?
at the moment i am using string.contentsEquals(stringbuffer) for my evaluations, ive had a look through the API and cannot find much to help me
Are you basically comparing two Strings to see if they are the same, despite differences in capitalisation, or where one starts with the value of the other? There are methods on the String class that do this. Also, if your passing the String 'dav' to an SQL statement, you could use the sql 'like' command. Oracle also has an UPPER statement you could use.
hope this helps
Joined: Nov 24, 2004
would like the case to be case insensitive, and to be able to type in a substring of a word and return all results containing that substring. i completely forgot about the like cause in mysql (not used it in a while) i shall have a look in my book see what i can do with it.
Joined: Feb 14, 2006
I suspect that you'll also want to determine if the flavour of SQL you're using supports an 'UPPER' clause. That way you can do your search in one statement.
Otherwise, you'll need to change the case of your search string (using the appropriate String API methods) and perform: a search for the String as passed in; a search in lowercase; a search in uppercase; title case? random case? arrrgggg!!