my dog learned polymorphism*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
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