1 25 26 package org.objectweb.jonas.jtests.tables; 27 28 import java.rmi.RemoteException ; 29 import java.sql.Connection ; 30 import java.sql.Statement ; 31 32 import javax.naming.NamingException ; 33 34 import org.objectweb.util.monolog.api.BasicLevel; 35 36 40 41 public class Ttier extends Tmanager { 42 private static final String T_TIER = "JT2_TIERS"; 43 private static final String T_TIERMOR = "JT2_TIEMOR"; 44 private static final String T_TIERPHY = "JT2_TIEPHY"; 45 46 51 public static void init() throws NamingException , RemoteException { 52 mgrInit(); 53 createTables(); 54 } 55 56 60 private static void createTables() throws RemoteException { 61 62 Connection conn = null; 64 try { 65 conn = dataSource.getConnection(); 66 } catch (Exception e) { 67 throw new RemoteException ("Cannot get Connection"); 68 } 69 70 Statement stmt; 71 try { 72 stmt = conn.createStatement(); 73 stmt.execute("DROP TABLE " + T_TIER); 74 logger.log(BasicLevel.INFO, "Table " + T_TIER + " dropped"); 75 stmt.execute("DROP TABLE " + T_TIERMOR); 76 logger.log(BasicLevel.INFO, "Table " + T_TIERMOR + " dropped"); 77 stmt.execute("DROP TABLE " + T_TIERPHY); 78 logger.log(BasicLevel.INFO, "Table " + T_TIERPHY + " dropped"); 79 stmt.close(); 80 } catch (Exception e) { 81 logger.log(BasicLevel.DEBUG, "Exception in drop Tables : " + e); 82 } 83 try { 84 stmt = conn.createStatement(); 86 stmt.execute("create table " + T_TIER 87 + "(NUMINTTIE INTEGER NOT NULL," 88 + "EMAILTIE VARCHAR(40), " 89 + "PRIMARY KEY (NUMINTTIE))"); 90 stmt.execute("insert into " + T_TIER + " values(1, 'admin@bull.net')"); 91 stmt.execute("insert into " + T_TIER + " values(2, 'admin@objectweb.org')"); 92 stmt.execute("insert into " + T_TIER + " values(100, 'helene.joanin@bull.net')"); 93 stmt.execute("insert into " + T_TIER + " values(101, 'adriana.danes@bull.net')"); 94 logger.log(BasicLevel.INFO, "Table " + T_TIER + " created"); 95 stmt = conn.createStatement(); 97 stmt.execute("create table " + T_TIERMOR 98 + "(NUMINTTIE INTEGER NOT NULL," 99 + "RAISOCTIE VARCHAR(40), " 100 + "PRIMARY KEY (NUMINTTIE))"); 101 stmt.execute("insert into " + T_TIERMOR + " values(1, 'bull')"); 102 stmt.execute("insert into " + T_TIERMOR + " values(2, 'objectweb')"); 103 logger.log(BasicLevel.INFO, "Table " + T_TIERMOR + " created"); 104 stmt = conn.createStatement(); 106 stmt.execute("create table " + T_TIERPHY 107 + "(NUMINTTIE INTEGER NOT NULL," 108 + "NOMUSATIE VARCHAR(40), " 109 + "PRIMARY KEY (NUMINTTIE))"); 110 stmt.execute("insert into " + T_TIERPHY + " values(100, 'helene joanin')"); 111 stmt.execute("insert into " + T_TIERPHY + " values(101, 'adriana danes')"); 112 logger.log(BasicLevel.INFO, "Table " + T_TIERPHY + " created"); 113 stmt.close(); 114 conn.close(); } catch (Exception e) { 116 logger.log(BasicLevel.ERROR, "Exception in create/init Table : " + e); 117 throw new RemoteException ("Exception in create/init Table : " + e); 118 } 119 } 120 121 } 122 123 124 | Popular Tags |