*
The moose likes JDBC and the fly likes Why my code is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Why my code is not working" Watch "Why my code is not working" New topic
Author

Why my code is not working

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

What isn't working with it? Be more descriptive? Do you get an error? What error? What line of code?


Steve
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
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

Joined: Apr 09, 2004
Posts: 112

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.


Each number system has exactly 10 different digits.
Matteo Di Furia
Ranch Hand

Joined: Jun 20, 2008
Posts: 102
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

Joined: Mar 22, 2008
Posts: 732
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

Joined: Oct 27, 2005
Posts: 19718
    
  20

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 "".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Problem solved

Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why my code is not working