1 21 22 27 28 package org.apache.derby.impl.drda; 29 30 import java.sql.Connection ; 31 import java.sql.SQLException ; 32 33 import javax.transaction.xa.XAResource ; 34 import javax.sql.XADataSource ; 35 import javax.sql.XAConnection ; 36 37 import java.util.Hashtable ; 38 import java.util.Properties ; 39 import java.util.Enumeration ; 40 41 42 import org.apache.derby.jdbc.EmbeddedXADataSource; 43 import org.apache.derby.impl.drda.DRDAXid; 44 import org.apache.derby.iapi.jdbc.BrokeredConnection; 45 import org.apache.derby.iapi.jdbc.EngineConnection; 46 47 class XADatabase extends Database { 48 49 50 private EmbeddedXADataSource xaDataSource; 52 53 private XAResource xaResource; 54 private XAConnection xaConnection; 55 56 57 XADatabase (String dbName) 58 { 59 super(dbName); 60 forXA = true; 61 } 62 63 67 synchronized void makeConnection(Properties p) throws 68 SQLException 69 { 70 if (xaDataSource == null) 71 { 72 xaDataSource = new EmbeddedXADataSource(); 73 } 74 75 xaDataSource.setDatabaseName(shortDbName); 76 appendAttrString(p); 77 if (attrString != null) 78 xaDataSource.setConnectionAttributes(attrString); 79 80 EngineConnection conn = getConnection(); 81 if (conn == null) 83 { 84 xaConnection = xaDataSource.getXAConnection(userId,password); 85 setXAResource(xaConnection.getXAResource()); 86 } 87 else { 89 conn.close(); 90 } 91 92 conn = (EngineConnection) xaConnection.getConnection(); 96 conn.setAutoCommit(false); 99 setConnection(conn); 100 } 101 102 105 protected void setXAResource (XAResource resource) 106 { 107 this.xaResource = resource; 108 } 109 110 113 protected XAResource getXAResource () 114 { 115 return this.xaResource; 116 } 117 118 119 } 120 121 122 123 124 125 126 127 128 129 | Popular Tags |