aspose file tools*
The moose likes JDBC and the fly likes Need Help Pulling Data From Oracle Table (Newby) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need Help Pulling Data From Oracle Table (Newby)" Watch "Need Help Pulling Data From Oracle Table (Newby)" New topic
Author

Need Help Pulling Data From Oracle Table (Newby)

K DeLucia
Ranch Hand

Joined: Apr 11, 2008
Posts: 68
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 ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Welcome to JavaRanch!

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
K DeLucia
Ranch Hand

Joined: Apr 11, 2008
Posts: 68
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help Pulling Data From Oracle Table (Newby)