Let me start of by saying I'm very new to Java so the code may be messy/poorly coded. However, I've come a long way already and it's almost working. What I'm trying to do is prompt the user to enter a type, then a key. I use that type to determine the SQL statement to use then I use the key as part of the SQL statement.
If I enter 'custnum' as the type, then a string as my key, it finds the record fine. If I any of my other valid types (lname, address or phone) and then enter my key, the result set is empty. I've verified that there are matching records for the type/key I'm entering.
I've tried stepping it through the debugger and looking at various variables along the way both with the working scenario and the not-working scenario, but I can't find anything. I'm sure it's a simple coding mistake, but I don't really know how to track it down.
Any ideas on what's going wrong would be greatly appreciated. Thanks!
[edited to disable smilies in code] [ April 11, 2008: Message edited by: Jeanne Boyarsky ]
If you try running the same query at the database command line, does it work?
My first guess is that maybe the database has extra whitespace in the column and it isn't matching. Another alternative is that the case of the strings are different. Both of these can be solved with a SQL change (TRIM or TO_UPPER) if they are in fact the problem.
Thanks so much for the reply. It was indeed due to a problem with the SQL statement. Some of the fields I was querying were a fixed length (apparently suffixed with spaces). Now on to the next step! Thanks much!