It's not a secret anymore!*
The moose likes JDBC and the fly likes What is the result of Prepared Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What is the result of Prepared Statement" Watch "What is the result of Prepared Statement" New topic
Author

What is the result of Prepared Statement

Pradeeep Sharma
Ranch Hand

Joined: Dec 04, 2008
Posts: 32
Hi,
I have created a registration form in JSP, which takes values from user and insert it into database. In this form i am using PreparedStatement interface to execute the querry. now i want that if user fills this form and press submit button and if putting values in database got failed, than user should informed that registration failed try again. For that could any one tell me that what will be the value of 'i' after perfoming :

i=preparedStatement.executeUpdate();

if registration failed.
Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hi Pradeeep,
Normally if the insert or update fails you will get a SQL Exception which you can catch and hadle it appropriately. If everything goes fine and still the row was not update you will get a return value of "0" for the method.

Please check the java documentation for more details.


Regards,
Sivaraman.L
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the result of Prepared Statement
 
Similar Threads
JSF Registration Form.
urgent help
User registration system using struts+hibernate
Any possible of doing 2 actions in single button using struts
Server-side validation causing bean data to vanish.