KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > init > I_tables


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id:
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.init;
27
28
29 import javax.rmi.PortableRemoteObject JavaDoc;
30 import javax.naming.InitialContext JavaDoc;
31 import javax.naming.Context JavaDoc;
32 import org.objectweb.jonas.jtests.ftables.DBEnvHome;
33 import org.objectweb.jonas.jtests.ftables.DBEnv;
34 /**
35  */

36 public class I_tables {
37
38
39  public static void main(String JavaDoc args[]) {
40  
41     Context JavaDoc initialContext = null;
42     try {
43         initialContext = new InitialContext JavaDoc();
44     } catch (Exception JavaDoc e) {
45         System.err.println("Cannot get initial context for JNDI: " + e);
46         System.exit(2);
47     }
48    
49     // Connecting to DBEnvHome thru JNDI
50
DBEnvHome home = null;
51     try {
52         home = (DBEnvHome)PortableRemoteObject.narrow(initialContext.lookup("ftablesDBEnvHome"), DBEnvHome.class);
53     } catch (Exception JavaDoc e) {
54         System.err.println( "Cannot lookup DBEnvHome: " + e);
55         System.exit(2);
56     }
57     // tables Bean creation
58
DBEnv t1 = null;
59     try {
60         System.out.println("Create a bean tables");
61         t1 = home.create();
62     } catch (Exception JavaDoc e) {
63         System.err.println("Cannot create tables Bean: " + e);
64         System.exit(2);
65     }
66
67     // Get args
68
for (int argn = 0; argn < args.length; argn++) {
69         String JavaDoc filename = args[argn];
70         // init tables
71
try {
72             t1.initTable(filename);
73        
74          } catch (Exception JavaDoc e) {
75            System.err.println("Cannot create tables Bean: " + e);
76            System.exit(2);
77
78         }
79
80 }
81 }
82 }
83
Popular Tags