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.Description; 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 TestTModelDescTable 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 descList = new Vector (); 74 descList.add(new Description("blah, blah, blah", "en")); 75 descList.add(new Description("Yadda, Yadda, Yadda", "it")); 76 descList.add(new Description("WhoobWhoobWhoobWhoob", "cy")); 77 descList.add(new Description("Haachachachacha", "km")); 78 79 String authorizedUserID = "sviens"; 80 81 txn.begin(connection); 83 84 TModelTable.insert(tModel, authorizedUserID, connection); 86 87 TModelDescTable.insert(tModelKey, descList, connection); 89 90 descList = TModelDescTable.select(tModelKey, connection); 92 93 TModelDescTable.delete(tModelKey, connection); 95 96 descList = TModelDescTable.select(tModelKey, connection); 98 99 txn.commit(); 101 } 102 catch (Exception ex) 103 { 104 try 105 { 106 txn.rollback(); 107 } 108 catch (java.sql.SQLException sqlex) 109 { 110 sqlex.printStackTrace(); 111 } 112 throw ex; 113 } 114 } 115 } 116 } 117 | Popular Tags |