Exemplo n.º 1
0
 /**
  * Creates an instance of this class.
  *
  * @param env the Berkeley DB environment
  * @param timeout the number of milliseconds the transaction should be allowed to run
  * @throws IllegalArgumentException if timeout is less than {@code 1}
  * @throws DbDatabaseException if an unexpected database problem occurs
  */
 JeTransaction(XAEnvironment env, long timeout) {
   this.env = env;
   if (timeout <= 0) {
     throw new IllegalArgumentException("Timeout must be greater than 0");
   }
   try {
     txn = env.beginTransaction(null, null);
     /* Avoid overflow -- BDB treats 0 as unlimited */
     long timeoutMicros = (timeout < (Long.MAX_VALUE / 1000)) ? timeout * 1000 : 0;
     txn.setTxnTimeout(timeoutMicros);
   } catch (DatabaseException e) {
     throw JeEnvironment.convertException(e, false);
   }
 }