*
The moose likes JDBC and the fly likes How to check whether data is inserted or not in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to check whether data is inserted or not in Java" Watch "How to check whether data is inserted or not in Java" New topic
Author

How to check whether data is inserted or not in Java

Deo Sharma
Greenhorn

Joined: Apr 14, 2012
Posts: 12
Hi,

I m trying to insert data in my Ms-access database using Java. Actually my data is inserted but how to check through code that whether data is inserted or not. What type of value is return by java insertion statement. I m not able to track this as it throw exception and every time my boolean value became false also when data is inserted because it throw exception even when my data got inserted. I want to return true when my data is inserted and want to return false when any exception is occur. Can you tell me which statement to use and how.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

if you are using a prepared statement (which is highly recommended use prepared statements) the executeUpdate statement returns the number of rows inserted.

but if you are getting an exception i would worry about that first.
 
wood burning stoves
 
subject: How to check whether data is inserted or not in Java