aspose file tools*
The moose likes JDBC and the fly likes Updating a record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Updating a record" Watch "Updating a record" New topic
Author

Updating a record

lucky soni
Greenhorn

Joined: Mar 18, 2013
Posts: 1

Not able to insert into access database....getiing a msg Row is added and .ldb file is getting created but the database has no new row added.
but able to query the database and get results
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
For inserting or manipulating with the database(i.e. for DML commands), you should use PreparedStatement instead of simple Statement.
Statement should be used normally for DDL commands like select, delete and so on.

Example:
PreparedStatement pst= con.prepareStatement(sql);

Also, catch SQLException and close the connection and PreparedStatement in the finally block(*very important*).
You should always close the connection.

Thanks,
Ashwini Kashyap | www.infocepts.com
 
Don't get me started about those stupid light bulbs.
 
subject: Updating a record