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.CategoryBag; 22 import org.apache.juddi.datatype.KeyedReference; 23 import org.apache.juddi.util.Config; 24 import org.apache.juddi.util.jdbc.Transaction; 25 26 29 class TestFindServiceByCategoryQuery 30 { 31 public static void main(String [] args) 32 throws Exception 33 { 34 Config.setStringProperty("juddi.useConnectionPool","true"); 37 38 Connection conn = null; 39 try { 40 conn = Database.aquireConnection(); 41 test(conn); 42 } 43 finally { 44 if (conn != null) 45 conn.close(); 46 } 47 } 48 49 public static void test(Connection connection) 50 throws Exception 51 { 52 String businessKey = "740d75b1-3cde-4547-85dd-9578cd3ea1cd"; 53 54 CategoryBag categoryBag = new CategoryBag(); 55 Vector keyedRefVector = new Vector (); 56 keyedRefVector.addElement(new KeyedReference("uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4","ntis-gov:NAICS:1997","51121")); 57 keyedRefVector.addElement(new KeyedReference("uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4","Mining","21")); 58 keyedRefVector.addElement(new KeyedReference("uuid:DB77450D-9FA8-45D4-A7BC-04411D14E384",null,"abcdefg")); 59 keyedRefVector.addElement(new KeyedReference("uuid:DB77450D-9FA8-45D4-A7BC-04411D14E384","1775f0f8-cd47-451d-88da-73ce508836f3","blah, blah, blah")); 60 categoryBag.setKeyedReferenceVector(keyedRefVector); 61 62 Vector keysIn = new Vector (); 63 keysIn.add("740d75b1-3cde-4547-85dd-9578cd3ea1cd"); 64 keysIn.add("c311085b-3277-470d-8ce9-07b81c484e4b"); 65 keysIn.add("6b368a5a-6a62-4f23-a002-f11e22780a91"); 66 keysIn.add("45994713-d3c3-40d6-87b5-6ce51f36001c"); 67 keysIn.add("901b15c5-799c-4387-8337-a1a35fceb791"); 68 keysIn.add("80fdae14-0e5d-4ea6-8eb8-50fde422056d"); 69 keysIn.add("e1996c33-c436-4004-9e3e-14de191bcc6b"); 70 keysIn.add("3ef4772f-e04b-46ed-8065-c5a4e167b5ba"); 71 72 Transaction txn = new Transaction(); 73 74 if (connection != null) 75 { 76 try 77 { 78 txn.begin(connection); 80 81 keysIn = FindServiceByCategoryQuery.select(businessKey,categoryBag,keysIn,null,connection); 82 83 for (int i=0; i< keyedRefVector.size(); i++) 84 { 85 KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i); 86 keysIn = FindServiceByCategoryQuery.select(businessKey,keyedRef,null,null,connection); 87 } 88 89 txn.commit(); 91 } 92 catch(Exception ex) 93 { 94 try { txn.rollback(); } 95 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 96 throw ex; 97 } 98 } 99 } 100 } 101 | Popular Tags |