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 Tsecured extends Tmanager { 37 38 41 public static void init() throws NamingException , RemoteException { 42 mgrInit(); 43 createTable("securedBaseEC"); 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_info varchar(30) not null primary key,"+ 72 "c_name varchar(30) )"); 73 74 stmt.close(); 75 conn.close(); } catch(Exception e) { 77 logger.log(BasicLevel.ERROR, "Exception in createTable : "+e); 78 throw new RemoteException ("Exception in createTable : "+e); 79 } 80 logger.log(BasicLevel.INFO, "Table "+name+" created"); 81 } 82 83 } 84 | Popular Tags |