• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to assign null or clean the resultset when nothing is found?

 
Marvin Legend
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to assign null or clean the resultset when nothing is found? example:
Select name from names where code = 0;

When this search does not return anything, I would like the resultset returned null because nothing was found, what is happening is that the resultset only updates the value when a result is found, when no result is found it keeps the last value, and when someone enters a name that does not exist in the table it always returns the last name found, this error delayed me a lot, and I found nothing that I could understand to solve my problem, thanks a lot guys! Have a nice day.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show some code? It sounds like you are somehow reusing the same ResultSet object.

The way this is supposed to work is that an empty ResultSet is returned and it returns false when you call rs.next().
 
Marvin Legend
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Can you show some code? It sounds like you are somehow reusing the same ResultSet object.

The way this is supposed to work is that an empty ResultSet is returned and it returns false when you call rs.next().


Yes! I plan to reuse the resultset! I cant post the code now, because im in work now sorry bro , but you are right! So you advise me to call the next () method or have any other advice to give me? Thanks bro.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would advise you NOT to reuse the resultset. Do a new query, get a new resultset. A new query has to be done and data has to be transferred anyway, so no harm in starting clean.

Also, I'm female. So let's not refer to me as "bro".

 
Marvin Legend
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:I would advise you NOT to reuse the resultset. Do a new query, get a new resultset. A new query has to be done and data has to be transferred anyway, so no harm in starting clean.

Also, I'm female. So let's not refer to me as "bro".


rs, Sorry Jeane,
I did not notice your nick was my total lack of attention, it will not happen again, I am Brazilian, I do not read English very well, his name is very beautiful you know? ;) Sorry, I will more calmly analyze the code and I will follow your advice, thanks for listening.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worries. If I don't say something, you wouldn't know next time either .
 
Marvin Legend
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:No worries. If I don't say something, you wouldn't know next time either .

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic