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

Queries not committing in transaction

 
Rusty Enisin
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this JDBC code where I need to insert a record and then get the id of that inserted column. Everything works fine until I run a threaded test that tries to do 10 of these at once. The problem is that everything seems to run OK. The log prints out the id. But when I query the database only the last record was inserted. All the others are not persisted. No exceptions are thrown.



So for each call two queries are being run. Even though these are being run in different threads, only the last one works. If I run them sequentially, not in threads, it all works.

The problem really being I am running this in a threaded environment in production...
 
Rusty Enisin
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arg. You work on something all morning and then finally post in desperation, only to figure it out 10 minutes later... I should have posted hours ago. Then I would have figured it out hours ago + 10 minutes...

The SQL for the identity select was incorrect. I was using this which is wrong:



This is wrong, wrong, wrong. And needless to say caused me heartburn. Here is the correct SQL.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic