Monday, April 15, 2013

resultSet.next() always returns “false”!!

You might be executing some query in your application and even though that you verified all the connection parameters like connection URL to the database, username and password, and the SQL statement that you fired, and that data also resides in the database in proper table and there are absolutely no case-related errors like “Scott” in place of “scott” user, resultSet.next() is always returning false.
The retrieved resultSet actually points initially to a location before the actual data index, so with first resultSet.next() call, the resultSet pointer now points to the first fetched record in the database.
This is ridiculous and has wasted considerable time as I pondered over evil things. Actually I failed to commit the data after inserting into the table. Without committing, that data never is written to the database schema really. So check, did you really do a
SQL> commit;
After scorching my head for a considerable time for these 7 characters of wisdom ( c-o-m-m-i-t-; ), I unleashed the forgotten thing:
DML commands need to be committed/rolled-back for changes to take effect. Find a small list here. Returning to basic command line always helps in this world of tools that abstract a lot of things.

7 comments:

  1. very thanks................ i was freaked with this goddamn small mistake now i getting the records

    ReplyDelete
  2. Oh. My. God. Thank you a lot, man ! I didn't such bad luck like yours, but still, I struggled myself for 3-4 hours trying to find a solution to that.

    ReplyDelete
    Replies
    1. You're welcome! 2 days not completely in that, but it was freaking me out :D Returning to basics always helps in the world where tools abstract a lot of things.

      Delete
  3. Thanks a ton!!!!! It saved alot of time !

    ReplyDelete
  4. Thank U..A freaky Error With Oracle but not Mysql..Any way ur idea helps

    ReplyDelete

Liked or hated the post? Leave your words of wisdom! Thank you :)