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.business.BusinessEntity; 22 import org.apache.juddi.datatype.business.Contact; 23 import org.apache.juddi.util.Config; 24 import org.apache.juddi.util.jdbc.Transaction; 25 import org.apache.juddi.uuidgen.UUIDGen; 26 import org.apache.juddi.uuidgen.UUIDGenFactory; 27 28 31 class TestContactTable 32 { 33 public static void main(String [] args) 34 throws Exception 35 { 36 Config.setStringProperty("juddi.useConnectionPool","true"); 39 40 Connection conn = null; 41 try { 42 conn = Database.aquireConnection(); 43 test(conn); 44 } 45 finally { 46 if (conn != null) 47 conn.close(); 48 } 49 } 50 51 public static void test(Connection connection) throws Exception 52 { 53 Transaction txn = new Transaction(); 54 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 55 56 if (connection != null) 57 { 58 try 59 { 60 String businessKey = uuidgen.uuidgen(); 61 BusinessEntity business = new BusinessEntity(); 62 business.setBusinessKey(businessKey); 63 business.setAuthorizedName("sviens"); 64 business.setOperator("www.jUDDI.org"); 65 66 Vector contactList = new Vector (); 67 Contact contact = null; 68 69 contact = new Contact("Steve Viens"); 70 contact.setUseType("sales"); 71 contactList.add(contact); 72 73 contact = new Contact("Marley Viens"); 74 contact.setUseType("support"); 75 contactList.add(contact); 76 77 contact = new Contact("Chris Michaels"); 78 contact.setUseType("marketing"); 79 contactList.add(contact); 80 81 String authorizedUserID = "sviens"; 82 83 txn.begin(connection); 85 86 BusinessEntityTable.insert(business, authorizedUserID, connection); 88 89 ContactTable.insert(businessKey, contactList, connection); 91 92 contactList = ContactTable.select(businessKey, connection); 94 95 System.out.println(contactList.size() + 96 " contacts for BusinessKey: "+businessKey); 97 98 ContactTable.delete(businessKey, connection); 100 101 contactList = ContactTable.select(businessKey, connection); 103 104 System.out.println(contactList.size() + 105 " contacts for BusinessKey: "+businessKey); 106 107 txn.commit(); 109 } 110 catch (Exception ex) 111 { 112 try 113 { 114 txn.rollback(); 115 } 116 catch (java.sql.SQLException sqlex) 117 { 118 sqlex.printStackTrace(); 119 } 120 throw ex; 121 } 122 } 123 } 124 } 125 | Popular Tags |