KickJava   Java API By Example, From Geeks To Geeks.

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


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 (steve@users.sourceforge.net)
25  */

26 class TestPublisherAssertionTable
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         // begin a new transaction
55
txn.begin(connection);
56
57         // commit the transaction
58
txn.commit();
59       }
60       catch (Exception JavaDoc ex)
61       {
62         try
63         {
64           txn.rollback();
65         }
66         catch (java.sql.SQLException JavaDoc sqlex)
67         {
68           sqlex.printStackTrace();
69         }
70         throw ex;
71       }
72     }
73   }
74 }
75
Popular Tags