File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Insert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Insert" Watch "Insert" New topic



Joined: Dec 06, 2002
Posts: 2
I'm struggling with inserting a record to Access 97 database.
The java program should insert one record into a table in a Access database which is allowed to read and write. I set up ODBC in the control panel->Data Sources(ODBC). The program seems working. However, it doesn't insert the record into that table. Strangely, when I use the same program, just change DSN to another database, it works fine. I just cannot think a reason which might cause the problem.
many thanks,

[ Edited by Dave to format code and remove smilies ]
[ December 09, 2002: Message edited by: David O'Meara ]
Sam Moran
Ranch Hand

Joined: Sep 28, 2002
Posts: 86
I got your email message over the weekend but could not respond. I have a couple of suggestion:
1) Have you thought about adding arguments to you connect statement?
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

I have not been able to get even read access to an Access DB without the arguments! It might be because I am using 1.3.1?!?!?
2) How about a new driver? For Access that is.
I hope this helps.

We make a living by what we get, we make a life by what we give!
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

This is a known bug of with Access 97. For the new record to show in the access database, do a trivial select on the table you inserted into after you complete the insert or close the connection. It's not your code I think you can also upgrade your access ODBC driver.
Also, you might want to have a connection.commit() because all drivers don't default to autocommit = true.
I agree. Here's the link:
subject: Insert
It's not a secret anymore!