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.Description; 22 import org.apache.juddi.datatype.business.BusinessEntity; 23 import org.apache.juddi.datatype.business.Contact; 24 import org.apache.juddi.datatype.business.Contacts; 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 TestContactDescTable 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) throws Exception 54 { 55 Transaction txn = new Transaction(); 56 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 57 58 if (connection != null) 59 { 60 try 61 { 62 Vector descList = new Vector (); 64 descList.add(new Description("blah, blah, blah", "en")); 65 descList.add(new Description("Yadda, Yadda, Yadda", "it")); 66 descList.add(new Description("WhoobWhoobWhoobWhoob", "cy")); 67 descList.add(new Description("Haachachachacha", "km")); 68 69 Contact contact = new Contact("Anthony Michaels"); 71 contact.setUseType("sales"); 72 contact.setDescriptionVector(descList); 73 74 Vector contactList = new Vector (); 76 contactList.add(contact); 77 Contacts contacts = new Contacts(); 78 contacts.setContactVector(contactList); 79 80 String businessKey = uuidgen.uuidgen(); 82 BusinessEntity business = new BusinessEntity(); 83 business.setBusinessKey(businessKey); 84 business.setAuthorizedName("sviens"); 85 business.setOperator("WebServiceRegistry.com"); 86 business.setContacts(contacts); 87 88 int contactID = 0; 89 90 txn.begin(connection); 92 93 String authorizedUserID = "sviens"; 94 95 BusinessEntityTable.insert(business, authorizedUserID, connection); 97 98 ContactTable.insert(businessKey, contactList, connection); 100 101 ContactDescTable.insert(businessKey, contactID, descList, connection); 103 104 descList = ContactDescTable.select(businessKey, contactID, connection); 106 107 ContactDescTable.delete(businessKey, connection); 109 110 descList = ContactDescTable.select(businessKey, contactID, connection); 112 113 txn.commit(); 115 } 116 catch (Exception ex) 117 { 118 try 119 { 120 txn.rollback(); 121 } 122 catch (java.sql.SQLException sqlex) 123 { 124 sqlex.printStackTrace(); 125 } 126 throw ex; 127 } 128 } 129 } 130 } 131 | Popular Tags |