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.request.FindQualifiers; 22 import org.apache.juddi.util.Config; 23 import org.apache.juddi.util.jdbc.Transaction; 24 25 28 class TestFindPublisherByNameQuery 29 { 30 public static void main(String [] args) 31 throws Exception 32 { 33 Config.setStringProperty("juddi.useConnectionPool","true"); 36 37 Connection conn = null; 38 try { 39 conn = Database.aquireConnection(); 40 test(conn); 41 } 42 finally { 43 if (conn != null) 44 conn.close(); 45 } 46 } 47 48 public static void test(Connection connection) 49 throws Exception 50 { 51 String name = new String ("Steve"); 52 53 Vector idsIn = null; 54 idsIn = new Vector (); 55 idsIn.add(new String ("sviens")); 56 idsIn.add(new String ("jdoe")); 57 idsIn.add(new String ("steveviens")); 58 59 Transaction txn = new Transaction(); 60 61 if (connection != null) 62 { 63 try 64 { 65 txn.begin(connection); 67 68 Vector results = FindPublisherByNameQuery.select(name,idsIn,null,connection); 69 if (results != null) 70 { 71 for (int i=0; i<results.size(); i++) 72 System.out.println(i+": "+(String )results.elementAt(i)); 73 } 74 75 FindQualifiers fqs = new FindQualifiers(); 76 fqs.sortByNameAsc = true; 77 78 Vector resutls2 = FindPublisherByNameQuery.select(name,null,fqs,connection); 79 if (results != null) 80 { 81 for (int i=0; i<resutls2.size(); i++) 82 System.out.println(i+": "+(String )resutls2.elementAt(i)); 83 } 84 85 fqs.exactNameMatch = true; 86 87 Vector resutls3 = FindPublisherByNameQuery.select(name,null,fqs,connection); 88 if (results != null) 89 { 90 for (int i=0; i<resutls3.size(); i++) 91 System.out.println(i+": "+(String )resutls3.elementAt(i)); 92 } 93 94 txn.commit(); 96 } 97 catch(Exception ex) 98 { 99 try { txn.rollback(); } 100 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 101 throw ex; 102 } 103 } 104 } 105 } | Popular Tags |