1 21 package org.apache.derbyTesting.functionTests.tests.lang; 22 23 import java.io.BufferedInputStream ; 24 import java.io.FileInputStream ; 25 import java.io.FileNotFoundException ; 26 import java.sql.Connection ; 27 import java.sql.PreparedStatement ; 28 import java.sql.SQLException ; 29 import java.sql.Statement ; 30 31 import org.apache.derby.impl.tools.ij.utilMain; 32 import org.apache.derby.tools.ij; 33 34 public class wisconsin { 35 36 public static void main(String [] args) throws Throwable { 37 ij.getPropertyArg(args); 38 Connection conn = ij.startJBMS(); 39 40 conn.setAutoCommit(false); 41 conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); 42 43 createTables(conn); 44 45 BufferedInputStream inStream; 46 47 String filePath = "wisc_setup.sql"; 49 50 try 51 { 52 inStream = new BufferedInputStream (new FileInputStream (filePath), 53 utilMain.BUFFEREDFILESIZE); 54 } catch (FileNotFoundException e) 55 { 56 System.out.println("unable to find input file "+filePath); 57 throw e; 58 } 59 60 ij.runScript(conn, inStream, "US-ASCII", 61 System.out, (String ) null); 62 conn.commit(); 63 } 64 65 private static void createTables(Connection conn) throws SQLException { 66 Statement stmt = conn.createStatement(); 67 68 stmt.execute("create table TENKTUP1 ( unique1 int not null, " + 69 "unique2 int not null, " + 70 "two int, " + 71 "four int, " + 72 "ten int, " + 73 "twenty int, " + 74 "onePercent int, " + 75 "tenPercent int, " + 76 "twentyPercent int, " + 77 "fiftyPercent int, " + 78 "unique3 int, " + 79 "evenOnePercent int, " + 80 "oddOnePercent int, " + 81 "stringu1 char(52) not null, " + 82 "stringu2 char(52) not null, " + 83 "string4 char(52) )"); 84 WISCInsert wi = new WISCInsert(); 86 wi.doWISCInsert(10000, "TENKTUP1", conn); 87 88 stmt.execute("create unique index TK1UNIQUE1 on TENKTUP1(unique1)"); 89 stmt.execute("create unique index TK1UNIQUE2 on TENKTUP1(unique2)"); 90 stmt.execute("create index TK1TWO on TENKTUP1(two)"); 91 stmt.execute("create index TK1FOUR on TENKTUP1(four)"); 92 stmt.execute("create index TK1TEN on TENKTUP1(ten)"); 93 stmt.execute("create index TK1TWENTY on TENKTUP1(twenty)"); 94 stmt.execute("create index TK1ONEPERCENT on TENKTUP1(onePercent)"); 95 stmt.execute("create index TK1TWENTYPERCENT on TENKTUP1(twentyPercent)"); 96 stmt.execute("create index TK1EVENONEPERCENT on TENKTUP1(evenOnePercent)"); 97 stmt.execute("create index TK1ODDONEPERCENT on TENKTUP1(oddOnePercent)"); 98 stmt.execute("create unique index TK1STRINGU1 on TENKTUP1(stringu1)"); 99 stmt.execute("create unique index TK1STRINGU2 on TENKTUP1(stringu2)"); 100 stmt.execute("create index TK1STRING4 on TENKTUP1(string4)"); 101 102 stmt.execute("create table TENKTUP2 (unique1 int not null, " + 103 "unique2 int not null, " + 104 "two int, " + 105 "four int, " + 106 "ten int, " + 107 "twenty int, " + 108 "onePercent int, " + 109 "tenPercent int, " + 110 "twentyPercent int, " + 111 "fiftyPercent int, " + 112 "unique3 int, " + 113 "evenOnePercent int, " + 114 "oddOnePercent int, " + 115 "stringu1 char(52), " + 116 "stringu2 char(52), " + 117 "string4 char(52) )"); 118 wi = new WISCInsert(); 120 wi.doWISCInsert(10000, "TENKTUP2", conn); 121 122 stmt.execute("create unique index TK2UNIQUE1 on TENKTUP2(unique1)"); 123 stmt.execute("create unique index TK2UNIQUE2 on TENKTUP2(unique2)"); 124 125 stmt.execute("create table ONEKTUP ( unique1 int not null, " + 126 "unique2 int not null, " + 127 "two int, " + 128 "four int, " + 129 "ten int, " + 130 "twenty int, " + 131 "onePercent int, " + 132 "tenPercent int, " + 133 "twentyPercent int, " + 134 "fiftyPercent int, " + 135 "unique3 int, " + 136 "evenOnePercent int, " + 137 "oddOnePercent int, " + 138 "stringu1 char(52), " + 139 "stringu2 char(52), " + 140 "string4 char(52) )"); 141 142 wi = new WISCInsert(); 144 wi.doWISCInsert(1000, "ONEKTUP", conn); 145 146 stmt.execute("create unique index ONEKUNIQUE1 on ONEKTUP(unique1)"); 147 stmt.execute("create unique index ONEKUNIQUE2 on ONEKTUP(unique2)"); 148 149 stmt.execute("create table BPRIME ( unique1 int, " + 150 "unique2 int, " + 151 "two int, " + 152 "four int, " + 153 "ten int, " + 154 "twenty int, " + 155 "onePercent int, " + 156 "tenPercent int, " + 157 "twentyPercent int, " + 158 "fiftyPercent int, " + 159 "unique3 int, " + 160 "evenOnePercent int, " + 161 "oddOnePercent int, " + 162 "stringu1 char(52), " + 163 "stringu2 char(52), " + 164 "string4 char(52))"); 165 166 stmt.execute("insert into BPRIME select * from TENKTUP2 where TENKTUP2.unique2 < 1000"); 167 168 conn.commit(); 169 170 PreparedStatement ps2 = conn.prepareStatement 171 ("call SYSCS_UTIL.SYSCS_COMPRESS_TABLE(?, ?, ?)"); 172 ps2.setString(1, "APP"); 173 ps2.setString(2, "BPRIME"); 174 ps2.setInt(3, 0); 175 ps2.executeUpdate(); 176 conn.commit(); 177 178 ps2.setString(1, "APP"); 179 ps2.setString(2, "TENKTUP1"); 180 ps2.setInt(3, 0); 181 ps2.executeUpdate(); 182 conn.commit(); 183 184 ps2.setString(1, "APP"); 185 ps2.setString(2, "TENKTUP2"); 186 ps2.setInt(3, 0); 187 ps2.executeUpdate(); 188 conn.commit(); 189 190 ps2.setString(1, "APP"); 191 ps2.setString(2, "ONEKTUP"); 192 ps2.setInt(3, 0); 193 ps2.executeUpdate(); 194 conn.commit(); 195 } 196 197 } 198 | Popular Tags |