Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert

 
wenting
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

wendy
[ Edited by Dave to format code and remove smilies ]
[ December 09, 2002: Message edited by: David O'Meara ]
 
Sam Moran
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"wenting",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
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.
Thanks.
Dave
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic