KickJava   Java API By Example, From Geeks To Geeks.

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


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

27 class TestFindTModelByNameQuery
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     String JavaDoc name = new String JavaDoc("");
51
52     Vector JavaDoc keysIn = new Vector JavaDoc();
53     keysIn.add("uuid:327A56F0-3299-4461-BC23-5CD513E95C55");
54     keysIn.add("uuid:4064C064-6D14-4F35-8953-9652106476A9");
55     keysIn.add("uuid:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88");
56     keysIn.add("uuid:807A2C6A-EE22-470D-ADC7-E0424A337C03");
57     keysIn.add("uuid:8609C81E-EE1F-4D5A-B202-3EB13AD01823");
58     keysIn.add("uuid:A035A07C-F362-44DD-8F95-E2B134BF43B4");
59     keysIn.add("uuid:B1B1BAF5-2329-43E6-AE13-BA8E97195039");
60     keysIn.add("uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2");
61     keysIn.add("uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4");
62     keysIn.add("uuid:CD153257-086A-4237-B336-6BDCBDCC6634");
63     keysIn.add("uuid:DB77450D-9FA8-45D4-A7BC-04411D14E384");
64     keysIn.add("uuid:E59AE320-77A5-11D5-B898-0004AC49CC1E");
65
66     Transaction txn = new Transaction();
67
68     if (connection != null)
69     {
70       try
71       {
72         // begin a new transaction
73
txn.begin(connection);
74
75         FindTModelByNameQuery.select(name,keysIn,null,connection);
76         FindTModelByNameQuery.select(name,null,null,connection);
77
78         // commit the transaction
79
txn.commit();
80       }
81       catch(Exception JavaDoc ex)
82       {
83         try { txn.rollback(); }
84         catch(java.sql.SQLException JavaDoc sqlex) { sqlex.printStackTrace(); }
85         throw ex;
86       }
87     }
88   }
89 }
90
Popular Tags