aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Updating a record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Updating a record" Watch "Updating a record" New topic

Updating a record

lucky soni

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.

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.

Ashwini Kashyap |
I agree. Here's the link:
subject: Updating a record