KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > datastore > jdbc > TestFindBindingByTModelKeyQuery


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.datastore.jdbc;
17
18 import java.sql.Connection JavaDoc;
19 import java.util.Vector JavaDoc;
20
21 import org.apache.juddi.datatype.TModelBag;
22 import org.apache.juddi.util.Config;
23 import org.apache.juddi.util.jdbc.Transaction;
24
25 /**
26  * @author Steve Viens (sviens@apache.org)
27  */

28 class TestFindBindingByTModelKeyQuery
29 {
30   public static void main(String JavaDoc[] args)
31     throws Exception JavaDoc
32   {
33     // make sure we're using a DBCP DataSource and
34
// not trying to use JNDI to aquire one.
35
Config.setStringProperty("juddi.useConnectionPool","true");
36
37     Connection JavaDoc 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 JavaDoc connection)
49     throws Exception JavaDoc
50   {
51     String JavaDoc serviceKey = "13411e97-24cf-43d1-bee0-455e7ec5e9fc";
52
53     TModelBag tModelBag = new TModelBag();
54     Vector JavaDoc tModelKeyVector = new Vector JavaDoc();
55     tModelKeyVector.addElement("2a33d7d7-2b73-4de9-99cd-d4c51c186bce");
56     tModelKeyVector.addElement("2a33d7d7-2b73-4de9-99cd-d4c51c186bce");
57     tModelBag.setTModelKeyVector(tModelKeyVector);
58
59     Vector JavaDoc keysIn = new Vector JavaDoc();
60     keysIn.add("13411e97-24cf-43d1-bee0-455e7ec5e9fc");
61     keysIn.add("3f244f19-7ba7-4c3e-a93e-ae33e530794b");
62     keysIn.add("3009f336-98c1-4193-a22f-fea73e79c909");
63     keysIn.add("3ef4772f-e04b-46ed-8065-c5a4e167b5ba");
64
65     Transaction txn = new Transaction();
66
67     if (connection != null)
68     {
69       try
70       {
71         // begin a new transaction
72
txn.begin(connection);
73
74         FindBindingByTModelKeyQuery.select(serviceKey,tModelBag,keysIn,null,connection);
75         FindBindingByTModelKeyQuery.select(serviceKey,tModelBag,null,null,connection);
76
77         // commit the transaction
78
txn.commit();
79       }
80       catch(Exception JavaDoc ex)
81       {
82         try { txn.rollback(); }
83         catch(java.sql.SQLException JavaDoc sqlex) { sqlex.printStackTrace(); }
84         throw ex;
85       }
86     }
87   }
88 }
89
Popular Tags