aspose file tools*
The moose likes JDBC and the fly likes Problem with query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with query" Watch "Problem with query" New topic
Author

Problem with query

michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
I know this is a simple query. When I try to execute in TOAD it is giving me the result. But when i put it in my application code it is not entering into rs.next loop

Not ure what is happening


can anybody suggest me where I am going wrong
michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
I have used even the LIKE operator but doesn't work

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I'm guessing that the unposted code which follows that looks like this:

In other words, your SQL is throwing an exception and you are ignoring it.
michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
Your right it is going to my Catch block
michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
Some thing wrong with Parenthesis
I get error 907
michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
I have removed the single Quotes that come after and before the % operator. It is not showing any sql Exception but still not executing

Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

Print out the error message of the exception, in stead of hiding it with this line:
System.out.println("Problem while reteriving the value for mencategory");

Run your program again, and you can read what's wrong.


OCUP UML fundamental and ITIL foundation
youtube channel
michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
I got the error 907 so i removed the quotes which I had put. After that I run the program I don't see any SQL error but still it is not entering in the rs.next loop.

Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

Remove the blanks after first and before the second %.


(and try switching to java.sql.PreparedStatement.
michell o'brien
Ranch Hand

Joined: Jun 09, 2009
Posts: 37
Thanks It worked.
Blank spaces were the problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with query