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

Synchronization issue with PreparedStatement

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All
I am facing a strange issue. We have to delete some roles from our application .As per business logic before deletion of roles we store them into ou archive table and once they are stored then we delete them from our main table

This logic works fine with single user environment but whenever testing is performed on multi user we are losing the roleName value of the record and getting exception from table


In our code we are first selecting the record from our main table VT_RE_ROLE
and putting it into dto.closing prepared ststement,resultset

opening another preparedststement and now using same dto tryin to insert this record

Sample code snippet is as follows


Some how the dto's name property is lost and therefore in subsequent preparedstatement it throws the error mentioned above

If any one can share some inputs that will be of great help

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav,
I see two inserts without a transaction. Is there a transaction wrapping the whole code (maybe it is called from a session bean or the like) ? If not, all sorts of synchronization/threading issues can occur without a transaction and you should add one.
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah all set of inserts are with in a same transaction
Therefore ideally shall be there any synchrnonization issues?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Chikara:
Yeah all set of inserts are with in a same transaction
Therefore ideally shall be there any synchrnonization issues?

If they are in a properly configured transaction, this shouldn't be able to happen. What setting are you using for the transaction?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic