Results 1 to 5 of 5
  1. #1
    ragav is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default Exception in thread "main" java.util.NoSuchElementException

    Hi i am using hashmap to store key & value pairs

    Before iterating thru hashmap i am checking !map.isEmpty() in
    while(!map.isEmpty() && iter.hasNext())
    It shows below error..
    Exception in thread "main" java.util.NoSuchElementException

    how to resolve this.

    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I wonder if you are calling one iter.next() more than once from within the while loop? What does the code within your loop look like?

  3. #3
    ragav is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default

    Thanks for ur reply..
    The below is my code snippets
    while(iter.hasNext()){
    while(rs.next()){
    selecting values from map
    insert into table with map values
    }
    }

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    given what you've posted, I have no idea. What is "rs" for instance? Why does it appear that you are not using your iterator even though you are first checking it in the first while condition?...

  5. #5
    ragav is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default

    Thanks for ur reply..

    I am using iterator for selecting value from map..
    Using rs.next() i am selecting value from one table
    and then insert both values (from hashmap & table ) into another table..

Similar Threads

  1. Replies: 5
    Last Post: 05-14-2008, 02:43 PM
  2. Replies: 1
    Last Post: 08-07-2007, 08:10 AM
  3. Replies: 1
    Last Post: 07-27-2007, 11:59 PM
  4. Replies: 1
    Last Post: 07-25-2007, 11:55 PM
  5. Replies: 1
    Last Post: 07-16-2007, 07:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •