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.Email; 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 TestEmailTable 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("Billy Bob"); 69 contact.setUseType("server"); 70 contactList.add(contact); 71 int contactID = 0; 72 73 Vector emailList = new Vector (); 74 Email email = null; 75 76 email = new Email("support@steveviens.com"); 77 email.setUseType("Support"); 78 emailList.add(email); 79 80 email = new Email("marketing@steveviens.com"); 81 email.setUseType("Advertising"); 82 emailList.add(email); 83 84 email = new Email("info@steveviens.com"); 85 email.setUseType("Information"); 86 emailList.add(email); 87 88 email = new Email("admin@steveviens.com"); 89 email.setUseType("Administration"); 90 emailList.add(email); 91 92 email = new Email("webmaster@steveviens.com"); 93 email.setUseType("Web Master"); 94 emailList.add(email); 95 96 String authorizedUserID = "sviens"; 97 98 txn.begin(connection); 100 101 BusinessEntityTable.insert(business, authorizedUserID, connection); 103 104 ContactTable.insert(businessKey, contactList, connection); 106 107 EmailTable.insert(businessKey, contactID, emailList, connection); 109 110 emailList = EmailTable.select(businessKey, contactID, connection); 112 113 EmailTable.delete(businessKey, connection); 115 116 emailList = EmailTable.select(businessKey, contactID, connection); 118 119 txn.commit(); 121 } 122 catch (Exception ex) 123 { 124 try 125 { 126 txn.rollback(); 127 } 128 catch (java.sql.SQLException sqlex) 129 { 130 sqlex.printStackTrace(); 131 } 132 throw ex; 133 } 134 } 135 } 136 } 137 | Popular Tags |