• Post Reply Bookmark Topic Watch Topic
  • New Topic

Insertion in Database using synchronisation block in multithreaded environment  RSS feed

 
Mani pradeep
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the synchronised block DB insertion is getting skipped for some of the records . Its happing rarely 1 out of 5 times
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're going to have to give a few more details than that. We've barely got enough details to even begin guessing what the problem might be.


Can you show us the code?
 
Mani pradeep
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Always use code tags; I added them to your post and doesn't it look better I also had to delete hundreds of tab characters which would have made the post completely illegible and would have introduced compiler and logic errors. Please always post correctly‑indented code.

You have a dangerous error in the form of that empty catch block. That means you can suffer exceptions and never know about them. You also have an error putting the close() call inside the try. The close() call should be in a finally or better in a try‑with‑resources. Otherwise there is a risk of the connection not being closed. Run the code again with those two corrections and see what happens.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!