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.KeyedReference; 22 import org.apache.juddi.datatype.business.BusinessEntity; 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 TestBusinessIdentifierTable 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("WebServiceRegistry.com"); 65 66 Vector keyRefs = new Vector (); 67 keyRefs.add(new KeyedReference(uuidgen.uuidgen(), "blah, blah, blah")); 68 keyRefs.add( 69 new KeyedReference(uuidgen.uuidgen(), "Yadda, Yadda, Yadda")); 70 keyRefs.add( 71 new KeyedReference(uuidgen.uuidgen(), "WhoobWhoobWhoobWhoob")); 72 keyRefs.add(new KeyedReference(uuidgen.uuidgen(), "Haachachachacha")); 73 74 String authorizedUserID = "sviens"; 75 76 txn.begin(connection); 78 79 BusinessEntityTable.insert(business, authorizedUserID, connection); 81 82 BusinessIdentifierTable.insert(businessKey, keyRefs, connection); 84 85 business.setBusinessKey(uuidgen.uuidgen()); 87 BusinessEntityTable.insert(business, authorizedUserID, connection); 88 89 BusinessIdentifierTable.insert( 91 business.getBusinessKey(), 92 keyRefs, 93 connection); 94 95 keyRefs = BusinessIdentifierTable.select(businessKey, connection); 97 98 BusinessIdentifierTable.delete(businessKey, connection); 100 101 keyRefs = BusinessIdentifierTable.select(businessKey, connection); 103 104 txn.commit(); 106 } 107 catch (Exception ex) 108 { 109 try 110 { 111 txn.rollback(); 112 } 113 catch (java.sql.SQLException sqlex) 114 { 115 sqlex.printStackTrace(); 116 } 117 throw ex; 118 } 119 } 120 } 121 } 122 | Popular Tags |