1 23 24 package com.sun.gjc.spi; 25 26 import com.sun.gjc.spi.ManagedConnection; 27 import javax.resource.ResourceException ; 28 import javax.resource.spi.LocalTransactionException ; 29 30 36 public class LocalTransaction implements javax.resource.spi.LocalTransaction { 37 38 private ManagedConnection mc; 39 40 46 public LocalTransaction(ManagedConnection mc) { 47 this.mc = mc; 48 } 49 50 57 public void begin() throws ResourceException { 58 mc.transactionStarted(); 60 try { 61 mc.getActualConnection().setAutoCommit(false); 62 } catch(java.sql.SQLException sqle) { 63 throw new LocalTransactionException (sqle.getMessage()); 64 } 65 } 66 67 73 public void commit() throws ResourceException { 74 Exception e = null; 75 try { 76 mc.getActualConnection().commit(); 77 mc.getActualConnection().setAutoCommit(true); 78 } catch(java.sql.SQLException sqle) { 79 throw new LocalTransactionException (sqle.getMessage()); 80 } 81 mc.transactionCompleted(); 83 } 84 85 92 public void rollback() throws ResourceException { 93 try { 94 mc.getActualConnection().rollback(); 95 mc.getActualConnection().setAutoCommit(true); 96 } catch(java.sql.SQLException sqle) { 97 throw new LocalTransactionException (sqle.getMessage()); 98 } 99 mc.transactionCompleted(); 101 } 102 103 } 104 | Popular Tags |