I agree, the proposed solution is the opposite of what you want. The problem is actually with the database itself. Some databases can be configured to perform case insensitive matching or not, and you need to check the database settings for this. I don't recall whether or not this configured on a table/field level granularity, you'd have to consult your database software.
One alternate solution is to perform the query than perform the case sensitive matching yourself using String.equals() with the returned data although this has some other minor drawbacks such as transmitting the password back to the user (security).
I dont think which ever Database it is, you will never get case insensitive results, you will get what you queried for ( that is the minimum contract of a query).
an execute() call returning true does not mean that it has returned some case insensitive results, this means that the query was executed successfully. return instead of what you are doing now, or use executeQuery() and then ResultSet's method to see if there were really any records in the result set. correct me if I am wrong.
I would suggest, use a Query to select count * From ... if it is not too expensive on the applicaiton process. [ October 25, 2005: Message edited by: RajaniKanth Bhargava ]
but this would make my query case insensitive... I don't think that is advisable when querying password fields right? I need it to be case sensitive like...
HELLO is not the same as hello...
Woops! Miss-read your post. Sorry. Scott Selikoff is right - you'll need to configure your database to be case sensitive. If that's not an option, you'll have to check that results in you applcaition after they are returned.
Anil Kumar Saha
Joined: Apr 07, 2004
What will be the solution if the database is DB2?
Anil Kumar Saha
Joined: Aug 29, 2002
Originally posted by Anil Kumar Saha: What will be the solution if the database is DB2?
If database is DB2 UDB, it should be case sensitive by default. To make it case insensitive we use UPPER() when comparing as outlined in the posts above.
Sab<br /> <br />Perfection does not come from belief or faith. Talk does not count for anything. Parrots can do that. Perfection comes through selfless work.<br />Swami Vivekananda
Sirish Kumar Gongal Reddy
Joined: Oct 25, 2004
Hi, The solution for your problem is while obtaining the Connection it self you need to select the type of connection i.e it may be a sensitive or insensitive.the code is like this,
DriverManger.registerDriver(Driver name here); Connection con=DriverManager.getConnection(url here); Statement stmt=con.createStatement(RESULTSET_TYPE_SENSITIVE OR INSENSITIVE); ResultSet rs=stmt.executeQuery(your Query here);
Hope that you got my point.If you have any concerns please put a mail then i'll come up with full code.