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 import javax.naming.NamingException ; 32 import javax.sql.DataSource ; 33 34 public class Tmessage { 35 36 static DataSource dataSource = null; 37 38 41 public static void init() throws NamingException , RemoteException { 42 43 dataSource = DBEnvSL.getDataSource("jdbc_1"); 45 46 createTable("messageMRecordEC"); 48 } 49 50 53 private static void createTable(String name) throws RemoteException { 54 55 Connection conn = null; 57 try { 58 conn = dataSource.getConnection(); 59 } catch(Exception e) { 60 throw new RemoteException ("Cannot get Connection"); 61 } 62 63 Statement stmt; 64 try { 65 stmt = conn.createStatement(); 66 stmt.execute("DROP TABLE "+name); 67 stmt.close(); 68 } catch(Exception e) { 69 } 70 try { 71 stmt = conn.createStatement(); 72 stmt.execute("create table " + name + 73 "(c_uuid varchar(20) not null, c_dest varchar(30), c_value integer, c_mdb varchar(30) not null,"+ 74 "primary key (c_uuid, c_mdb))"); 75 stmt.close(); 76 conn.close(); } catch(Exception e) { 78 System.err.println("Exception in createTable : "+e); 79 throw new RemoteException ("Exception in createTable : "+e); 80 } 81 } 82 83 } 84 85 | Popular Tags |