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 34 public class Tffolder { 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("ffolderFileECB", "c_count integer, c_p1pk varchar(30), c_p2pk varchar(30)"); 48 createTable("ffolderPaperECL", "c_value integer"); 49 } 50 51 54 private static void createTable(String name, String fields) 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 + "(c_name varchar(30) not null primary key," + fields + ")"); 74 stmt.close(); 75 conn.close(); } catch(Exception e) { 77 System.err.println("Exception in createTable : "+e); 78 throw new RemoteException ("Exception in createTable : "+e); 79 } 80 } 81 82 } 83 84 | Popular Tags |