File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Queries not committing in transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Queries not committing in transaction" Watch "Queries not committing in transaction" New topic
Author

Queries not committing in transaction

Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
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...


The squeaky wheel gets the grease. Well, that or replaced...
Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Queries not committing in transaction