This week's book giveaways are in the Cloud and AI/ML forums. We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line! See this thread and this one for details.
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?
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.
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).