001: /*
002:
003: Derby - Class org.apache.derbyTesting.functionTests.tests.lang.wisconsin
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021: package org.apache.derbyTesting.functionTests.tests.lang;
022:
023: import java.io.BufferedInputStream;
024: import java.io.FileInputStream;
025: import java.io.FileNotFoundException;
026: import java.sql.Connection;
027: import java.sql.PreparedStatement;
028: import java.sql.SQLException;
029: import java.sql.Statement;
030:
031: import org.apache.derby.impl.tools.ij.utilMain;
032: import org.apache.derby.tools.ij;
033:
034: public class wisconsin {
035:
036: public static void main(String[] args) throws Throwable {
037: ij.getPropertyArg(args);
038: Connection conn = ij.startJBMS();
039:
040: conn.setAutoCommit(false);
041: conn
042: .setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
043:
044: createTables(conn);
045:
046: BufferedInputStream inStream;
047:
048: // set input stream
049: String filePath = "wisc_setup.sql";
050:
051: try {
052: inStream = new BufferedInputStream(new FileInputStream(
053: filePath), utilMain.BUFFEREDFILESIZE);
054: } catch (FileNotFoundException e) {
055: System.out.println("unable to find input file " + filePath);
056: throw e;
057: }
058:
059: ij.runScript(conn, inStream, "US-ASCII", System.out,
060: (String) null);
061: conn.commit();
062: }
063:
064: private static void createTables(Connection conn)
065: throws SQLException {
066: Statement stmt = conn.createStatement();
067:
068: stmt
069: .execute("create table TENKTUP1 ( unique1 int not null, "
070: + "unique2 int not null, "
071: + "two int, "
072: + "four int, "
073: + "ten int, "
074: + "twenty int, "
075: + "onePercent int, "
076: + "tenPercent int, "
077: + "twentyPercent int, "
078: + "fiftyPercent int, "
079: + "unique3 int, "
080: + "evenOnePercent int, "
081: + "oddOnePercent int, "
082: + "stringu1 char(52) not null, "
083: + "stringu2 char(52) not null, "
084: + "string4 char(52) )");
085: //--insert 10000 rows into TENKTUP1
086: WISCInsert wi = new WISCInsert();
087: wi.doWISCInsert(10000, "TENKTUP1", conn);
088:
089: stmt
090: .execute("create unique index TK1UNIQUE1 on TENKTUP1(unique1)");
091: stmt
092: .execute("create unique index TK1UNIQUE2 on TENKTUP1(unique2)");
093: stmt.execute("create index TK1TWO on TENKTUP1(two)");
094: stmt.execute("create index TK1FOUR on TENKTUP1(four)");
095: stmt.execute("create index TK1TEN on TENKTUP1(ten)");
096: stmt.execute("create index TK1TWENTY on TENKTUP1(twenty)");
097: stmt
098: .execute("create index TK1ONEPERCENT on TENKTUP1(onePercent)");
099: stmt
100: .execute("create index TK1TWENTYPERCENT on TENKTUP1(twentyPercent)");
101: stmt
102: .execute("create index TK1EVENONEPERCENT on TENKTUP1(evenOnePercent)");
103: stmt
104: .execute("create index TK1ODDONEPERCENT on TENKTUP1(oddOnePercent)");
105: stmt
106: .execute("create unique index TK1STRINGU1 on TENKTUP1(stringu1)");
107: stmt
108: .execute("create unique index TK1STRINGU2 on TENKTUP1(stringu2)");
109: stmt.execute("create index TK1STRING4 on TENKTUP1(string4)");
110:
111: stmt.execute("create table TENKTUP2 (unique1 int not null, "
112: + "unique2 int not null, " + "two int, " + "four int, "
113: + "ten int, " + "twenty int, " + "onePercent int, "
114: + "tenPercent int, " + "twentyPercent int, "
115: + "fiftyPercent int, " + "unique3 int, "
116: + "evenOnePercent int, " + "oddOnePercent int, "
117: + "stringu1 char(52), " + "stringu2 char(52), "
118: + "string4 char(52) )");
119: //-- insert 10000 rows into TENKTUP2
120: wi = new WISCInsert();
121: wi.doWISCInsert(10000, "TENKTUP2", conn);
122:
123: stmt
124: .execute("create unique index TK2UNIQUE1 on TENKTUP2(unique1)");
125: stmt
126: .execute("create unique index TK2UNIQUE2 on TENKTUP2(unique2)");
127:
128: stmt.execute("create table ONEKTUP ( unique1 int not null, "
129: + "unique2 int not null, " + "two int, " + "four int, "
130: + "ten int, " + "twenty int, " + "onePercent int, "
131: + "tenPercent int, " + "twentyPercent int, "
132: + "fiftyPercent int, " + "unique3 int, "
133: + "evenOnePercent int, " + "oddOnePercent int, "
134: + "stringu1 char(52), " + "stringu2 char(52), "
135: + "string4 char(52) )");
136:
137: //-- insert 1000 rows into ONEKTUP
138: wi = new WISCInsert();
139: wi.doWISCInsert(1000, "ONEKTUP", conn);
140:
141: stmt
142: .execute("create unique index ONEKUNIQUE1 on ONEKTUP(unique1)");
143: stmt
144: .execute("create unique index ONEKUNIQUE2 on ONEKTUP(unique2)");
145:
146: stmt.execute("create table BPRIME ( unique1 int, "
147: + "unique2 int, " + "two int, " + "four int, "
148: + "ten int, " + "twenty int, " + "onePercent int, "
149: + "tenPercent int, " + "twentyPercent int, "
150: + "fiftyPercent int, " + "unique3 int, "
151: + "evenOnePercent int, " + "oddOnePercent int, "
152: + "stringu1 char(52), " + "stringu2 char(52), "
153: + "string4 char(52))");
154:
155: stmt
156: .execute("insert into BPRIME select * from TENKTUP2 where TENKTUP2.unique2 < 1000");
157:
158: conn.commit();
159:
160: PreparedStatement ps2 = conn
161: .prepareStatement("call SYSCS_UTIL.SYSCS_COMPRESS_TABLE(?, ?, ?)");
162: ps2.setString(1, "APP");
163: ps2.setString(2, "BPRIME");
164: ps2.setInt(3, 0);
165: ps2.executeUpdate();
166: conn.commit();
167:
168: ps2.setString(1, "APP");
169: ps2.setString(2, "TENKTUP1");
170: ps2.setInt(3, 0);
171: ps2.executeUpdate();
172: conn.commit();
173:
174: ps2.setString(1, "APP");
175: ps2.setString(2, "TENKTUP2");
176: ps2.setInt(3, 0);
177: ps2.executeUpdate();
178: conn.commit();
179:
180: ps2.setString(1, "APP");
181: ps2.setString(2, "ONEKTUP");
182: ps2.setInt(3, 0);
183: ps2.executeUpdate();
184: conn.commit();
185: }
186:
187: }
|