KickJava   Java API By Example, From Geeks To Geeks.

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


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

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