This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes executeUpdate() return Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "executeUpdate() return" Watch "executeUpdate() return" New topic

executeUpdate() return

sumit gandhi

Joined: Aug 13, 2007
Posts: 2
Need your help on this one.I am using PreparedStatment to update the database records.Now, I want to throw Application exception on the basis of returned value from executeUpdate(). What should be the condition to throw exception?
int intReturn = pstmtUpdate.executeUpdate();
if (intReturn ??? 0) {
else {
<throw exception>
??? in above condition should be >,>= . Please respond.}
Medha Jhunjhunwala

Joined: Sep 06, 2007
Posts: 9
intReturn will have the number of rows updated. So, if you think that updation of 0 rows is an exception, then use intReturn > 0 as success condition.

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Maybe you can make use of 'execute' in place of executeUpdate.
sumit gandhi

Joined: Aug 13, 2007
Posts: 2
Thanks Medha and Abhishek for your responses.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: executeUpdate() return
Similar Threads
auto commit within JTS transaction
Throwing multiple exception
Unavailable Exception Problem
Custom if then else tags?
this is wot my codes like