1 25 26 package org.objectweb.jonas.jtests.ftables; 27 28 import java.rmi.RemoteException ; 29 import java.sql.Connection ; 30 import java.sql.Statement ; 31 import javax.naming.NamingException ; 32 import javax.sql.DataSource ; 33 37 public class Tfannuaire extends Tmanager { 38 39 42 public static void init() throws NamingException , RemoteException { 43 mgrInit(); 44 45 createTable("fannuairePersonneEC"); 46 47 } 48 49 52 private static void createTable(String name) throws RemoteException { 53 54 Connection conn = null; 56 try { 57 conn = dataSource.getConnection(); 58 } catch(Exception e) { 59 throw new RemoteException ("Cannot get Connection"); 60 } 61 62 Statement stmt; 63 try { 64 65 stmt = conn.createStatement(); 66 stmt.execute("DROP TABLE "+name); 67 stmt.close(); 68 } catch(Exception e) { 70 } 72 try { 73 stmt = conn.createStatement(); 74 stmt.execute("create table " + name + 75 "(c_nom varchar(30) not null primary key,"+ "c_numero varchar(10))"); 76 77 stmt.execute("insert into "+name+" values('Philippe Coq', '1235456')"); 78 stmt.execute("insert into "+name+" values('Philippe Durieux', '638')"); 79 stmt.execute("insert into "+name+" values('Adriana Danes', '1233456')"); 80 stmt.execute("insert into "+name+" values('Helene Joanin', '1230456')"); 81 stmt.execute("insert into "+name+" values('Gerard Vandome', '1232456')"); 82 stmt.execute("insert into "+name+" values('Francois Exertier', '1323456')"); 83 stmt.execute("insert into "+name+" values('Emmanuel Facarde', '1234356')"); 84 stmt.execute("insert into "+name+" values('Charly Mingus', '1238456')"); 85 stmt.execute("insert into "+name+" values('Thelonious Monk', '1239456')"); 86 stmt.execute("insert into "+name+" values('Jean-Luc Richard', '1203456')"); 87 88 for (int i = 0; i < 1000; i++) { 90 stmt.execute("insert into "+name+" values('"+ Integer.toString(i)+"', 'FF')"); 91 } 92 93 stmt.close(); 94 conn.close(); } catch(Exception e) { 96 throw new RemoteException ("Exception in createTable : "+e); 98 } 99 } 101 102 } 103 104 105 | Popular Tags |