• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with query

 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used even the LIKE operator but doesn't work

 
Paul Clapham
Sheriff
Posts: 21969
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your right it is going to my Catch block
 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some thing wrong with Parenthesis
I get error 907
 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2620
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2620
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the blanks after first and before the second %.


(and try switching to java.sql.PreparedStatement.
 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks It worked.
Blank spaces were the problem
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!