• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between JDBC based transaction and the Java Transaction API  RSS feed

 
Siddhant Agarwal
Greenhorn
Posts: 9
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just beginning to work on a  JAVA based project under which I have an option to use either a JDBC based transaction or the Java Transaction API? Now, I am not much aware of both of them, but I went through few posts online. However, I couldn't really understand when to use which one? How do we differentiate what would suit our need under which scenario?
 
Campbell Ritchie
Marshal
Posts: 56197
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's move you to our databases forum.

Don't know about the transaction API, but I know that transactions aren't part of JDBC; they are part of the database program. The database can run a transaction for you and you use JDBC to request a transaction. A transaction in a database runs to completion before anything else is committed to memory. During a transaction no other code may access the information used in that transaction. I would think you are better off looking for an SQL/databases tutorial and looking for its section about transactions (or you may have a book about databases, or lecture notes about databases). I would take it for granted that the tutorial/lecture/book would explain what ACID means. I think a tutorial/book/lecture would be better than finding a post.
 
Tim Moores
Saloon Keeper
Posts: 3953
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main difference between JDBC transactions and the JTA is that JTA supports transactions across DBs, something that is beyond JDBC. So unless you need to synchronize two or more DBs, I suggest to stick to JDBC transactions.

Campbell Ritchie wrote:A transaction in a database runs to completion before anything else is committed to memory. During a transaction no other code may access the information used in that transaction.

That depends on the transaction isolation level used by the DB, a concept that is supported by the JDBC (although not all DBs supports all the levels than JDBC does).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!