KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 import org.apache.juddi.datatype.KeyedReference;
21 import org.apache.juddi.util.Config;
22 import org.apache.juddi.util.jdbc.Transaction;
23
24 /**
25  * @author Steve Viens (sviens@apache.org)
26  */

27 class TestFindRelatedBusinessQuery
28 {
29   public static void main(String JavaDoc[] args)
30     throws Exception JavaDoc
31   {
32     // make sure we're using a DBCP DataSource and
33
// not trying to use JNDI to aquire one.
34
Config.setStringProperty("juddi.useConnectionPool","true");
35
36     Connection JavaDoc conn = null;
37     try {
38       conn = Database.aquireConnection();
39       test(conn);
40     }
41     finally {
42       if (conn != null)
43         conn.close();
44     }
45   }
46
47   public static void test(Connection JavaDoc connection)
48     throws Exception JavaDoc
49   {
50     Transaction txn = new Transaction();
51
52     KeyedReference keyedRef = new KeyedReference();
53     keyedRef.setTModelKey("");
54     keyedRef.setKeyName("");
55     keyedRef.setKeyValue("");
56
57     if (connection != null)
58     {
59       try
60       {
61         // begin a new transaction
62
txn.begin(connection);
63
64         FindRelatedBusinessQuery.select("2a33d7d7-2b73-4de9-99cd-d4c51c186bce",connection);
65         FindRelatedBusinessQuery.selectWithKeyedRef("2a33d7d7-2b73-4de9-99cd-d4c51c186bce",keyedRef,connection);
66
67         // commit the transaction
68
txn.commit();
69       }
70       catch(Exception JavaDoc ex)
71       {
72         try { txn.rollback(); }
73         catch(java.sql.SQLException JavaDoc sqlex) { sqlex.printStackTrace(); }
74         throw ex;
75       }
76     }
77   }
78 }
Popular Tags