Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Result set empty

 
Pranav Bhatt
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Basically i was makaing out one application. I had got the connection successfully, but when i iterate the resultset am getting no values as well as its size too is 0. Below am posting out the excerpts of my code and the output i'am getting. Can anyone please advice why its so? Though when am running the same query in DB itself its fetching me results??


and am getting the values as below too, which confirms that connection is successful.

Inside DAO 1-------------------------- weblogic.jdbc.wrapper.PoolConnection_oracle_jdbc_driver_T4CConnection@b
Inside DAO 2-------------------------- weblogic.jdbc.wrapper.Statement_oracle_jdbc_driver_T4CStatement@c
Inside DAO 3-------------------------- weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl@d


But when the below code executes just after the above one-:

do{
if(!rs.next()){
System.out.println("rs is not having anymore values !!!");
break;}
//some logic for query
}
} while(true);


Am coming out of the loop and getting result as-:

rs is not having anymore values !!!

[ May 07, 2008: Message edited by: pranav bhatt ]
 
Scott Selikoff
author
Saloon Keeper
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an odd way to do a while loop for a resultset, or more generally, its not often you see a do/while loop anymore.

As for your issue, I'm sure its related to the query. If its not throwing an error than your answer is pretty straight forward, the query returns no records. We would need to need to see your query and database structure to help any further, but I suggest you take the query and try to run it in a command line browser. You can also cut some of the conditionals (where) clauses out and see if you get data.

In some circumstances, table access is restricted for certain database logins, so make sure the user you connect with has proper rights to the database (ideally, connect with the user that created the tables for debugging).
 
Pranav Bhatt
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Scott for the valuable feedback, i tried some other query its working fine. actually the new query is having more than one row but the previous one was having just one row as output. May be something wrong with the iteration !! i will try to check that out.
Thanks
 
Pranav Bhatt
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Well it was my stupidity only :p . I only made inserts for that query and didnt commit it :p . Everthing resolved now. Thanks
[ May 09, 2008: Message edited by: pranav bhatt ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic