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.jonas.jtests.util.Env; 35 import org.objectweb.util.monolog.api.BasicLevel; 36 37 41 public class Tpdouble extends Tmanager { 42 43 46 public static void init() throws NamingException , RemoteException { 47 mgrInit(); 48 createTable("JT_EtypePdoubleEC"); 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 logger.log(BasicLevel.INFO, "Table "+name+" dropped"); 70 } catch(Exception e) { 71 logger.log(BasicLevel.DEBUG, "Exception in dropTable : \n"+e); 72 } 73 try { 74 int dbType = Env.getDatabaseType(conn); 75 String cTypeName; 76 if ((dbType==Env.DB_ORACLE) || (dbType==Env.DB_POSGRESQL)) { 77 cTypeName = "double precision"; 78 } else { 79 cTypeName = "double"; 81 } 82 stmt = conn.createStatement(); 83 stmt.execute("create table " + name + 84 "( c_pk varchar(30) not null primary key, c_f1 "+cTypeName+")"); 85 stmt.execute("insert into "+name+" values('pk1', 1.0)"); 86 stmt.execute("insert into "+name+" values('pk2', 2.0)"); 87 stmt.execute("insert into "+name+" values('pk3', 3.0)"); 88 stmt.execute("insert into "+name+" values('pk4', 4.0)"); 89 stmt.execute("insert into "+name+" values('pk5', 5.0)"); 90 stmt.execute("insert into "+name+" values('pk5bis', 5.0)"); 91 stmt.execute("insert into "+name+" values('pktoremove', 10000.0)"); 92 93 stmt.close(); 94 conn.close(); } catch(Exception e) { 96 logger.log(BasicLevel.ERROR, "Exception in createTable : "+e); 97 throw new RemoteException ("Exception in createTable : "+e); 98 } 99 logger.log(BasicLevel.INFO, "Table "+name+" created"); 100 } 101 102 } 103 | Popular Tags |