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 Ttransacted { 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("transactedSimpleEB"); 48 createTable("transactedSimpleEC"); 49 } 50 51 54 private static void createTable(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) { 70 } 71 try { 72 stmt = conn.createStatement(); 73 stmt.execute("create table " + name + 74 "(c_accno varchar(12) not null primary key,"+ 75 "c_customer varchar(20), c_balance integer, c_ident integer, c_count integer )"); 76 stmt.execute("insert into "+name+" values('pk1', 'NotSupported', 4, 0, 0)"); 77 stmt.execute("insert into "+name+" values('pk2', 'Required', 8, 0, 0)"); 78 stmt.execute("insert into "+name+" values('pk3', 'Never', 16, 0, 0)"); 79 stmt.execute("insert into "+name+" values('pk4', 'RequiresNew', 32, 0, 0)"); 80 stmt.execute("insert into "+name+" values('pk5', 'Mandatory', 64, 0, 0)"); 81 stmt.execute("insert into "+name+" values('pk6', 'Supports', 128, 0, 0)"); 82 stmt.close(); 83 conn.close(); } catch(Exception e) { 85 System.err.println("Exception in createTable : "+e); 86 throw new RemoteException ("Exception in createTable : "+e); 87 } 88 } 89 90 } 91 92 93 | Popular Tags |