• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why my code is not working

 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What isn't working with it? Be more descriptive? Do you get an error? What error? What line of code?
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that I am not receiving any error and all the 3 statements are not working.

What I want to achieve is to see first that the email doesn't exists in email table(email column) if exist then update if not exists then insert into database

Please check why the above code is working at all.

Regards
 
Peter van de Riet
Ranch Hand
Posts: 112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the email doesn't exists then the statement rs.next() return false. I think you have to move the else-part to the other if.
 
Matteo Di Furia
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be a stupid consideration, but based on which database you use and how you retrieve connections to it, you must explicitly call the method commit() on Connection to actually save data on the database. Just my 2 cents.
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter van de Riet:
If the email doesn't exists then the statement rs.next() return false. I think you have to move the else-part to the other if.


its update the email now if exists but not inserting new record into db

Regards
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your global structure now? It should be:

Unless coemail is zero or more % symbols (so including the empty string), the email field will never equal "".
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved

Thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic