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 40 public class Tobigd extends Tmanager { 41 44 public static void init() throws NamingException , RemoteException { 45 mgrInit(); 46 createTable("JT_EtypeObigdecimalEC"); 47 } 48 49 52 private static void createTable(String name) throws RemoteException { 53 54 Connection conn = null; 56 try { 57 conn = dataSource.getConnection(); 58 } catch(Exception e) { 59 throw new RemoteException ("Cannot get Connection"); 60 } 61 62 Statement stmt; 63 try { 64 stmt = conn.createStatement(); 65 stmt.execute("DROP TABLE "+name); 66 stmt.close(); 67 logger.log(BasicLevel.INFO, "Table "+name+" dropped"); 68 } catch(Exception e) { 69 logger.log(BasicLevel.DEBUG, "Exception in dropTable : \n"+e); 70 } 71 try { 72 stmt = conn.createStatement(); 73 stmt.execute("create table " + name + 74 "( c_pk varchar(30) not null primary key, c_f1 numeric )"); 75 stmt.execute("insert into "+name+" values('pk1', 1)"); 76 stmt.execute("insert into "+name+" values('pk2', 2)"); 77 stmt.execute("insert into "+name+" values('pk3', 3)"); 78 stmt.execute("insert into "+name+" values('pk4', 4)"); 79 stmt.execute("insert into "+name+" values('pk5', 5)"); 80 stmt.execute("insert into "+name+" values('pk5bis', 5)"); 81 stmt.execute("insert into "+name+" values('pktoremove', 10000)"); 82 stmt.execute("insert into "+name+" values('pknull', NULL)"); 83 stmt.execute("insert into "+name+" values('pkchangenull', 10000)"); 84 85 stmt.close(); 86 conn.close(); } catch(Exception e) { 88 logger.log(BasicLevel.ERROR, "Exception in createTable : "+e); 89 throw new RemoteException ("Exception in createTable : "+e); 90 } 91 logger.log(BasicLevel.INFO, "Table "+name+" created"); 92 } 93 94 } 95 | Popular Tags |