Transaction Status in JDBC

Is there a way to find out if a transaction is in the โ€œcurrentโ€ state in JDBC? I did not find anything in the connection API .

thanks

+5
source share
1 answer

JDBC does not track transaction status. The task of the database is to monitor the status of the transaction.

Given that you still have two ways to track / check transaction status.

You can make a sql call to your db to request transaction details. for oracle, this will be in the v $ transaction table suggested in this post .

SELECT COUNT(*) 
  FROM v$transaction t, v$session s, v$mystat 
  WHERE t.ses_addr = s.saddr AND s.sid = m.sid AND ROWNUM = 1;

, ( , Spring ).

public interface Session {
  public abstract org.hibernate.Transaction getTransaction();
}

public Transaction {
  public abstract boolean wasRolledBack() throws org.hibernate.HibernateException;

  public abstract boolean wasCommitted() throws org.hibernate.HibernateException;

  public abstract boolean isActive() throws org.hibernate.HibernateException;
}
+4

All Articles