1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 import java.util.Vector ; 20 21 import org.apache.juddi.datatype.Address; 22 import org.apache.juddi.datatype.business.BusinessEntity; 23 import org.apache.juddi.datatype.business.Contact; 24 import org.apache.juddi.util.Config; 25 import org.apache.juddi.util.jdbc.Transaction; 26 import org.apache.juddi.uuidgen.UUIDGen; 27 import org.apache.juddi.uuidgen.UUIDGenFactory; 28 29 32 class TestAddressTable 33 { 34 public static void main(String [] args) 35 throws Exception 36 { 37 Config.setStringProperty("juddi.useConnectionPool","true"); 40 41 Connection conn = null; 42 try { 43 conn = Database.aquireConnection(); 44 test(conn); 45 } 46 finally { 47 if (conn != null) 48 conn.close(); 49 } 50 } 51 52 public static void test(Connection connection) throws Exception 53 { 54 Transaction txn = new Transaction(); 55 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 56 57 if (connection != null) 58 { 59 try 60 { 61 String authorizedUserID = "sviens"; 62 63 String businessKey = uuidgen.uuidgen(); 64 BusinessEntity business = new BusinessEntity(); 65 business.setBusinessKey(businessKey); 66 business.setAuthorizedName("sviens"); 67 business.setOperator("WebServiceRegistry.com"); 68 69 Vector contactList = new Vector (); 70 Contact contact = new Contact("Bill Bob"); 71 contact.setUseType("server"); 72 contactList.add(contact); 73 int contactID = 0; 74 75 Vector addrList = new Vector (); 76 Address address = null; 77 78 address = new Address(); 79 address.setUseType("Mailing"); 80 address.setSortCode("a"); 81 addrList.add(address); 82 83 address = new Address(); 84 address.setUseType("Shipping"); 85 address.setSortCode("b"); 86 addrList.add(address); 87 88 address = new Address(); 89 address.setUseType("Marketing"); 90 address.setSortCode("c"); 91 addrList.add(address); 92 93 address = new Address(); 94 address.setUseType("Sales"); 95 address.setSortCode("d"); 96 addrList.add(address); 97 98 address = new Address(); 99 address.setUseType("Engineering"); 100 address.setSortCode("e"); 101 addrList.add(address); 102 103 txn.begin(connection); 105 106 BusinessEntityTable.insert(business, authorizedUserID, connection); 108 109 ContactTable.insert(businessKey, contactList, connection); 111 112 AddressTable.insert(businessKey, contactID, addrList, connection); 114 115 addrList = AddressTable.select(businessKey, contactID, connection); 117 118 AddressTable.delete(businessKey, connection); 120 121 addrList = AddressTable.select(businessKey, contactID, connection); 123 124 txn.commit(); 126 } 127 catch (Exception ex) 128 { 129 try { 130 txn.rollback(); 131 } 132 catch (java.sql.SQLException sqlex) { 133 sqlex.printStackTrace(); 134 } 135 136 throw ex; 137 } 138 } 139 } 140 } | Popular Tags |