File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 1106

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check whether data is inserted or not in Java
 
Similar Threads
How to find insert/update/delete queries are successful in PreparedStatements[solved]
what is retBoolean
Full stack testing of java web application with selenium
How to manage CMP field with Boolean type????
try, catch, finally and return