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 Tinherit extends Tmanager { 37 38 41 public static void init() throws NamingException , RemoteException { 42 mgrInit(); 43 createTable("inheritUserEC"); 44 } 45 46 49 private static void createTable(String name) throws RemoteException { 50 51 Connection conn = null; 53 try { 54 conn = dataSource.getConnection(); 55 } catch(Exception e) { 56 throw new RemoteException ("Cannot get Connection"); 57 } 58 59 Statement stmt; 60 try { 61 stmt = conn.createStatement(); 62 stmt.execute("DROP TABLE "+name); 63 stmt.close(); 64 logger.log(BasicLevel.INFO, "Table "+name+" dropped"); 65 } catch(Exception e) { 66 logger.log(BasicLevel.DEBUG, "Exception in dropTable : \n"+e); 67 } 68 try { 69 stmt = conn.createStatement(); 70 stmt.execute("create table " + name + "(" + 71 "c_id integer not null,"+ 72 "c_idBis integer not null,"+ 73 "c_name varchar(50),"+ 74 "c_age integer,"+ 75 "c_password varchar(50),"+ 76 "primary key (c_id, c_idBis) )" 77 ); 78 79 stmt.close(); 80 conn.close(); } catch(Exception e) { 82 logger.log(BasicLevel.ERROR, "Exception in createTable : "+e); 83 throw new RemoteException ("Exception in createTable : "+e); 84 } 85 logger.log(BasicLevel.INFO, "Table "+name+" created"); 86 } 87 88 } 89 | Popular Tags |