wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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 | www.infocepts.com
It is sorta covered in the JavaRanch Style Guide.
subject: Updating a record
Similar Threads
not able to get values into database
user registration via Servlet/JSP/JDBC
BMP Entity EJBs and create()
insert statement
Not insert in database