File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing One table with multiple Threads and Inserting Values

 
Guneet Aulakh
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow members!

I am trying to save values to a table in Access, I have 3 threads that update this single table, but it seems to be overwriting the values in the table. Could any of you please guide me on what I am dooing wrong. The code is as follows:

Here are the 3 threads:


Here is the part from the run() where I call the JDBC:


Here is the part where we Update and Read the DB:



Here is the output

Thread : Thread-0
Data from Init_Cell: 0
Data from Final_Cell: 18

Thread : Thread-1
Data from Init_Cell: 4
Data from Final_Cell: 13

Thread : Thread-2
Data from Init_Cell: 7
Data from Final_Cell: 14

When I check the Table in the DB all is see is the last entry of 7 and 14, while the rest are missing!

Your suggestions and support are much appreciated.

Guneet

[edited to disable smilies]
[ December 27, 2004: Message edited by: Jeanne Boyarsky ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33689
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guneet,
Welcome to JavaRanch!

What do you expect to see? Each time the update statement runs, it overwrites the previous values in the table. So after the threads are finished, you would see the results of whatever thread happened to run last.
 
Guneet Aulakh
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please forgive my ignorance, but should I be trying Insert here, rather then update. It is 12 in the night! I will try with the insert, first thing in the morning, and post a reply here.

Thanks

Guneet
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33689
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guneet,
Yes! It should work with insert.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic