1 16 package org.apache.juddi.util.jdbc; 17 18 import java.sql.Connection ; 19 import java.sql.SQLException ; 20 import java.util.Vector ; 21 22 32 public class Transaction 33 { 34 37 private Vector vect = null; 38 39 42 public Transaction() 43 { 44 this.vect = new Vector (); 45 } 46 47 53 public void begin(Connection conn) 54 throws SQLException 55 { 56 if (conn.getAutoCommit() == true) 58 conn.setAutoCommit(false); 59 60 for (int i=0; i<vect.size(); i++) 63 { 64 if ((Connection )(vect.elementAt(i)) == conn) 65 return; 66 } 67 68 vect.add(conn); 70 } 71 72 75 public void commit() 76 throws SQLException 77 { 78 for (int i=0; i<vect.size(); i++) 80 { 81 Connection conn = (Connection )vect.elementAt(i); 82 conn.commit(); 83 } 84 85 vect.removeAllElements(); 87 } 88 89 92 public void rollback() 93 throws SQLException 94 { 95 for (int i=0; i<vect.size(); i++) 97 { 98 Connection conn = (Connection )vect.elementAt(i); 99 conn.rollback(); 100 } 101 102 vect.removeAllElements(); 104 } 105 } 106 | Popular Tags |