Is there a way to know if a transaction is in an “ongoing” state in JDBC? I found nothing in the Connection API.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
JDBC does not track the transaction state. It is the job of DB to track the transaction state.
Given that, you still have two ways on tracking/knowing the transaction states.
You can make a sql call to your db to ask for transaction specific detail. for oracle, it will be in v$transaction table in suggested in this post.
Another solution is to use transaction manager code in some common frameworks, such as hibernate (I believe Spring has it too).