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 Tfbasic extends Tmanager { 38 39 42 public static void init() throws NamingException , RemoteException { 43 mgrInit(); 44 createTableSimple("fbasicSimpleEB"); 45 } 50 51 54 private static void createTableSimple(String name) throws RemoteException { 55 56 Connection conn = null; 58 try { 59 conn = dataSource.getConnection(); 60 } catch(Exception e) { 61 throw new RemoteException ("Cannot get Connection"); 62 } 63 64 Statement stmt; 65 try { 66 stmt = conn.createStatement(); 67 stmt.execute("DROP TABLE "+name); 68 stmt.close(); 69 } catch(Exception e) { 71 } 73 try { 74 stmt = conn.createStatement(); 75 stmt.execute("create table " + name + 76 "(c_testname varchar(30) not null primary key,"+ 77 "c_info integer, c_numtest integer )"); 78 stmt.execute("insert into "+name+" values('pk1', 10, 4)"); 79 stmt.execute("insert into "+name+" values('pk2', 10, 4)"); 80 stmt.execute("insert into "+name+" values('pk3', 10, 4)"); 81 stmt.execute("insert into "+name+" values('pk4', 40, 8)"); 82 stmt.execute("insert into "+name+" values('pk5', 50, 8)"); 83 stmt.execute("insert into "+name+" values('pk6', 60, 8)"); 84 stmt.execute("insert into "+name+" values('pk7', 70, 8)"); 85 stmt.execute("insert into "+name+" values('pk8', 45, 20)"); 86 stmt.execute("insert into "+name+" values('pk9', 55, 30)"); 87 stmt.execute("insert into "+name+" values('pk10',80, 80)"); 88 stmt.execute("insert into "+name+" values('pk11',80, 80)"); 89 stmt.execute("insert into "+name+" values('pk12',90, 90)"); 90 stmt.execute("insert into "+name+" values('pk13',100, 90)"); 91 stmt.execute("insert into "+name+" values('pk14',110, 90)"); 92 93 94 stmt.close(); 95 conn.close(); } catch(Exception e) { 97 throw new RemoteException ("Exception in createTable : "+e); 99 } 100 } 102 103 106 private static void createTableAccount(String name) throws RemoteException { 107 108 Connection conn = null; 110 try { 111 conn = dataSource.getConnection(); 112 } catch(Exception e) { 113 throw new RemoteException ("Cannot get Connection"); 114 } 115 116 Statement stmt; 117 try { 118 stmt = conn.createStatement(); 119 stmt.execute("DROP TABLE "+name); 120 stmt.close(); 121 } catch(Exception e) { 123 } 125 try { 126 stmt = conn.createStatement(); 127 stmt.execute("create table " + name + 128 "(c_number integer not null primary key,"+ 129 " c_customer varchar(30) )"); 130 stmt.execute("insert into "+name+" values(0, 'to be removed')"); 131 stmt.execute("insert into "+name+" values(10, 'Eric')"); 132 stmt.execute("insert into "+name+" values(20, 'Helene')"); 133 stmt.execute("insert into "+name+" values(30, 'Guilhem')"); 134 stmt.execute("insert into "+name+" values(40, 'Malva')"); 135 136 stmt.close(); 137 conn.close(); } catch(Exception e) { 139 throw new RemoteException ("Exception in createTable : "+e); 141 } 142 } 144 145 148 private static void createTablePerson(String name) throws RemoteException { 149 150 Connection conn = null; 152 try { 153 conn = dataSource.getConnection(); 154 } catch(Exception e) { 155 throw new RemoteException ("Cannot get Connection"); 156 } 157 158 Statement stmt; 159 try { 160 stmt = conn.createStatement(); 161 stmt.execute("DROP TABLE "+name); 162 stmt.close(); 163 } catch(Exception e) { 165 } 167 try { 168 stmt = conn.createStatement(); 169 stmt.execute("create table " + name + 170 "(c_number integer not null primary key,"+ 171 " c_name varchar(30) )"); 172 stmt.execute("insert into "+name+" values(0, 'to be removed')"); 173 stmt.execute("insert into "+name+" values(10, 'Eric')"); 174 stmt.execute("insert into "+name+" values(20, 'Helene')"); 175 stmt.execute("insert into "+name+" values(30, 'Guilhem')"); 176 stmt.execute("insert into "+name+" values(40, 'Malva')"); 177 178 stmt.close(); 179 conn.close(); } catch(Exception e) { 181 throw new RemoteException ("Exception in createTable : "+e); 183 } 184 } 186 187 190 private static void createTablePkAuto(String name) throws RemoteException { 191 192 Connection conn = null; 194 try { 195 conn = dataSource.getConnection(); 196 } catch(Exception e) { 197 throw new RemoteException ("Cannot get Connection"); 198 } 199 200 Statement stmt; 201 try { 202 stmt = conn.createStatement(); 203 stmt.execute("DROP TABLE "+name); 204 stmt.close(); 205 } catch(Exception e) { 207 } 209 try { 210 stmt = conn.createStatement(); 211 stmt.execute("create table " + name + 212 "(c_field1 integer, c_field2 integer, c_field3 integer not null primary key )"); 213 214 stmt.close(); 215 conn.close(); } catch(Exception e) { 217 throw new RemoteException ("Exception in createTable : "+e); 219 } 220 } 222 223 224 } 225 | Popular Tags |