wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Insert or Update using prepared statement in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Insert or Update using prepared statement in java" Watch "Insert or Update using prepared statement in java" New topic
Author

Insert or Update using prepared statement in java

seena mathew
Greenhorn

Joined: Jun 14, 2009
Posts: 20
Hi, I am a newbee in Java.
What I want to do in my program is to
1) insert a new row in case the row doesn't exist OR
2) Update the row if the row exists

I checked the api and didn't find anything
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19728
    
  10

Pseudocode:

Unless of course your database has an "UPDATE-IF-ROW-EXISTS-ELSE-INSERT" command in its version of SQL. (Most of them don't.) But this would be a question about your database, rather than about JDBC.
Sudheer Bhat
Ranch Hand

Joined: Feb 22, 2011
Posts: 75
If you are using Oracle as your DB, you can use MERGE statement.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Insert or Update using prepared statement in java
 
It's not a secret anymore!