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.OverviewDoc; 23 import org.apache.juddi.datatype.tmodel.TModel; 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 TestTModelIdentifierTable 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 OverviewDoc overviewDoc = new OverviewDoc(); 62 overviewDoc.setOverviewURL( 63 "http://www.steveviens.com/overviewdoc.html"); 64 65 String tModelKey = uuidgen.uuidgen(); 66 TModel tModel = new TModel(); 67 tModel.setTModelKey(tModelKey); 68 tModel.setAuthorizedName("sviens"); 69 tModel.setOperator("WebServiceRegistry.com"); 70 tModel.setName("Tuscany Web Service Company"); 71 tModel.setOverviewDoc(overviewDoc); 72 73 Vector keyRefs = new Vector (); 74 keyRefs.add(new KeyedReference(uuidgen.uuidgen(), "blah, blah, blah")); 75 keyRefs.add( 76 new KeyedReference(uuidgen.uuidgen(), "Yadda, Yadda, Yadda")); 77 keyRefs.add( 78 new KeyedReference(uuidgen.uuidgen(), "WhoobWhoobWhoobWhoob")); 79 keyRefs.add(new KeyedReference(uuidgen.uuidgen(), "Haachachachacha")); 80 81 String authorizedUserID = "sviens"; 82 83 txn.begin(connection); 85 86 TModelTable.insert(tModel, authorizedUserID, connection); 88 89 TModelIdentifierTable.insert(tModelKey, keyRefs, connection); 91 92 tModel.setTModelKey(uuidgen.uuidgen()); 94 TModelTable.insert(tModel, authorizedUserID, connection); 95 96 TModelIdentifierTable.insert( 98 tModel.getTModelKey(), 99 keyRefs, 100 connection); 101 102 keyRefs = TModelIdentifierTable.select(tModelKey, connection); 104 105 TModelIdentifierTable.delete(tModelKey, connection); 107 108 keyRefs = TModelIdentifierTable.select(tModelKey, connection); 110 111 txn.commit(); 113 } 114 catch (Exception ex) 115 { 116 try 117 { 118 txn.rollback(); 119 } 120 catch (java.sql.SQLException sqlex) 121 { 122 sqlex.printStackTrace(); 123 } 124 throw ex; 125 } 126 } 127 } 128 } 129 | Popular Tags |