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 public class Tbeanexc extends Tmanager { 37 38 41 public static void init() throws NamingException , RemoteException { 42 mgrInit(); 43 createTable("beanexcAccountEB"); 44 createTable("beanexcAccountEC"); 45 } 46 47 50 private static void createTable(String name) throws RemoteException { 51 52 Connection conn = null; 54 try { 55 conn = dataSource.getConnection(); 56 } catch(Exception e) { 57 throw new RemoteException ("Cannot get Connection"); 58 } 59 60 Statement stmt; 61 try { 62 stmt = conn.createStatement(); 63 stmt.execute("DROP TABLE "+name); 64 stmt.close(); 65 logger.log(BasicLevel.INFO, "Table "+name+" dropped"); 66 } catch(Exception e) { 67 logger.log(BasicLevel.DEBUG, "Exception in dropTable : \n"+e); 68 } 69 try { 70 stmt = conn.createStatement(); 71 stmt.execute("create table " + name + 72 "(c_number integer not null primary key,"+ 73 "c_customer varchar(30), c_balance integer )"); 74 stmt.execute("insert into "+name+" values(101,'Antoine de St Exupery',900)"); 75 stmt.execute("insert into "+name+" values(102,'Alexandre Dumas fils',500)"); 76 stmt.execute("insert into "+name+" values(103,'Conan Doyle',800)"); 77 stmt.execute("insert into "+name+" values(104,'Alfred de Musset',140)"); 78 stmt.execute("insert into "+name+" values(105,'Phileas Lebegue',235)"); 79 stmt.execute("insert into "+name+" values(81, 'Philippe Coq',20)"); 80 stmt.execute("insert into "+name+" values(82, 'Philippe Durieux',20)"); 81 stmt.execute("insert into "+name+" values(83, 'Helene Joanin',20)"); 82 stmt.execute("insert into "+name+" values(84, 'Adriana Danes',20)"); 83 stmt.execute("insert into "+name+" values(85, 'Francois Exertier',20)"); 84 stmt.execute("insert into "+name+" values(86, 'John Doo', 20)"); 85 stmt.execute("insert into "+name+" values(87, 'Jim', 20)"); 86 stmt.execute("insert into "+name+" values(999990, 'For exception in ejbRemove', 20)"); 88 stmt.execute("insert into "+name+" values(999991, 'For exception in ejbRemove', 20)"); 89 stmt.execute("insert into "+name+" values(999992, 'For exception in ejbRemove', 20)"); 90 stmt.execute("insert into "+name+" values(999993, 'For exception in ejbRemove', 20)"); 91 stmt.close(); 92 conn.close(); } catch(Exception e) { 94 logger.log(BasicLevel.ERROR, "Exception in createTable : "+e); 95 throw new RemoteException ("Exception in createTable : "+e); 96 } 97 logger.log(BasicLevel.INFO, "Table "+name+" created"); 98 } 99 100 } 101 102 103 | Popular Tags |