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.AddressLine; 23 import org.apache.juddi.datatype.business.BusinessEntity; 24 import org.apache.juddi.datatype.business.Contact; 25 import org.apache.juddi.util.Config; 26 import org.apache.juddi.util.jdbc.Transaction; 27 import org.apache.juddi.uuidgen.UUIDGen; 28 import org.apache.juddi.uuidgen.UUIDGenFactory; 29 30 33 class TestAddressLineTable 34 { 35 public static void main(String [] args) 36 throws Exception 37 { 38 Config.setStringProperty("juddi.useConnectionPool","true"); 41 42 Connection conn = null; 43 try { 44 conn = Database.aquireConnection(); 45 test(conn); 46 } 47 finally { 48 if (conn != null) 49 conn.close(); 50 } 51 } 52 53 public static void test(Connection connection) 54 throws Exception 55 { 56 Transaction txn = new Transaction(); 57 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 58 59 if (connection != null) 60 { 61 try 62 { 63 String authorizedUserID = "sviens"; 64 65 String businessKey = uuidgen.uuidgen(); 66 BusinessEntity business = new BusinessEntity(); 67 business.setBusinessKey(businessKey); 68 business.setAuthorizedName("sviens"); 69 business.setOperator("WebServiceRegistry.com"); 70 71 Contact contact = new Contact(); 72 contact.setPersonNameValue("Bill Bob"); 73 contact.setUseType("server"); 74 75 Vector contactList = new Vector (); 76 contactList.add(contact); 77 int contactID = 0; 78 79 Address address = new Address(); 80 address.setUseType("Mailing"); 81 address.setSortCode("a"); 82 83 Vector addrList = new Vector (); 84 addrList.add(address); 85 int addressID = 0; 86 87 AddressLine addrLine1 = new AddressLine(); 88 addrLine1.setLineValue("SteveViens.com, Inc."); 89 90 AddressLine addrLine2 = new AddressLine(); 91 addrLine2.setLineValue("PO BOX 6856"); 92 93 AddressLine addrLine3 = new AddressLine(); 94 addrLine3.setLineValue("78 Marne Avenue"); 95 96 AddressLine addrLine4 = new AddressLine(); 97 addrLine4.setLineValue("Portsmouth"); 98 99 AddressLine addrLine5 = new AddressLine(); 100 addrLine5.setLineValue("New Hampshire"); 101 102 Vector lineList = new Vector (); 103 lineList.add(addrLine1); 104 lineList.add(addrLine2); 105 lineList.add(addrLine3); 106 lineList.add(addrLine4); 107 lineList.add(addrLine5); 108 109 txn.begin(connection); 111 112 BusinessEntityTable.insert(business,authorizedUserID,connection); 114 115 ContactTable.insert(businessKey,contactList,connection); 117 118 AddressTable.insert(businessKey,contactID,addrList,connection); 120 121 AddressLineTable.insert(businessKey,contactID,addressID,lineList,connection); 123 124 lineList = AddressLineTable.select(businessKey,contactID,addressID,connection); 126 127 130 lineList = AddressLineTable.select(businessKey,contactID,addressID,connection); 132 133 txn.commit(); 135 } 136 catch(Exception ex) 137 { 138 try { txn.rollback(); } 139 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 140 throw ex; 141 } 142 } 143 } 144 } 145 | Popular Tags |