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.Phone; 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 TestPhoneTable 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 businessKey = uuidgen.uuidgen(); 62 BusinessEntity business = new BusinessEntity(); 63 business.setBusinessKey(businessKey); 64 business.setAuthorizedName("sviens"); 65 business.setOperator("WebServiceRegistry.com"); 66 67 Vector contactList = new Vector (); 68 Contact contact = new Contact("John Smith"); 69 contact.setUseType("tech support"); 70 contactList.add(contact); 71 int contactID = 0; 72 73 Vector phoneList = new Vector (); 74 Phone phone = null; 75 76 phone = new Phone("603.457.8110"); 77 phone.setUseType("Voice Mailbox"); 78 phoneList.add(phone); 79 80 phone = new Phone("603.457.8111"); 81 phone.setUseType("Fax"); 82 phoneList.add(phone); 83 84 phone = new Phone("603.457.8112"); 85 phone.setUseType("Mobil"); 86 phoneList.add(phone); 87 88 phone = new Phone("603.457.8113"); 89 phone.setUseType("Pager"); 90 phoneList.add(phone); 91 92 String authorizedUserID = "sviens"; 93 94 txn.begin(connection); 96 97 BusinessEntityTable.insert(business, authorizedUserID, connection); 99 100 ContactTable.insert(businessKey, contactList, connection); 102 103 PhoneTable.insert(businessKey, contactID, phoneList, connection); 105 106 phoneList = PhoneTable.select(businessKey, contactID, connection); 108 109 PhoneTable.delete(businessKey, connection); 111 112 phoneList = PhoneTable.select(businessKey, contactID, connection); 114 115 txn.commit(); 117 } 118 catch (Exception ex) 119 { 120 try 121 { 122 txn.rollback(); 123 } 124 catch (java.sql.SQLException sqlex) 125 { 126 sqlex.printStackTrace(); 127 } 128 throw ex; 129 } 130 } 131 } 132 } 133 | Popular Tags |