001: /*
002: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
003: * (license2)
004: * Initial Developer: H2 Group
005: */
006: package org.h2.test.bench;
007:
008: import java.math.BigDecimal;
009: import java.sql.PreparedStatement;
010: import java.sql.Timestamp;
011: import java.sql.Types;
012:
013: /**
014: * This test is similar to the TPC-C test of the Transaction Processing Council
015: * (TPC). Only one connection and one thread is used. Referential integrity is
016: * not implemented.
017: * <p>
018: * See also http://www.tpc.org
019: */
020: public class BenchC implements Bench {
021:
022: private Database db;
023:
024: int warehouses = 1;
025: int items = 10000;
026: int districtsPerWarehouse = 10;
027: int customersPerDistrict = 300;
028: private int ordersPerDistrict = 300;
029:
030: private BenchCRandom random;
031: private String action;
032:
033: private int commitEvery = 1000;
034:
035: // private final static String[] OPERATION_TEXT = { "Neworder", "Payment",
036: // "Order Status", "Delivery (deferred)", "Delivery (interactive)",
037: // "Stock-level" };
038: //
039: private static final String[] TABLES = new String[] { "WAREHOUSE",
040: "DISTRICT", "CUSTOMER", "HISTORY", "ORDERS", "NEW_ORDER",
041: "ITEM", "STOCK", "ORDER_LINE", "RESULTS" };
042: private static final String[] CREATE_SQL = new String[] {
043: "CREATE TABLE WAREHOUSE(\n"
044: + " W_ID INT NOT NULL PRIMARY KEY,\n"
045: + " W_NAME VARCHAR(10),\n"
046: + " W_STREET_1 VARCHAR(20),\n"
047: + " W_STREET_2 VARCHAR(20),\n"
048: + " W_CITY VARCHAR(20),\n" + " W_STATE CHAR(2),\n"
049: + " W_ZIP CHAR(9),\n" + " W_TAX DECIMAL(4, 4),\n"
050: + " W_YTD DECIMAL(12, 2))",
051: "CREATE TABLE DISTRICT(\n" + " D_ID INT NOT NULL,\n"
052: + " D_W_ID INT NOT NULL,\n"
053: + " D_NAME VARCHAR(10),\n"
054: + " D_STREET_1 VARCHAR(20),\n"
055: + " D_STREET_2 VARCHAR(20),\n"
056: + " D_CITY VARCHAR(20),\n" + " D_STATE CHAR(2),\n"
057: + " D_ZIP CHAR(9),\n" + " D_TAX DECIMAL(4, 4),\n"
058: + " D_YTD DECIMAL(12, 2),\n"
059: + " D_NEXT_O_ID INT,\n"
060: + " PRIMARY KEY (D_ID, D_W_ID))", // ,\n"
061: // + " FOREIGN KEY (D_W_ID)\n"
062: // + " REFERENCES WAREHOUSE(W_ID))",
063: "CREATE TABLE CUSTOMER(\n" + " C_ID INT NOT NULL,\n"
064: + " C_D_ID INT NOT NULL,\n"
065: + " C_W_ID INT NOT NULL,\n"
066: + " C_FIRST VARCHAR(16),\n"
067: + " C_MIDDLE CHAR(2),\n" + " C_LAST VARCHAR(16),\n"
068: + " C_STREET_1 VARCHAR(20),\n"
069: + " C_STREET_2 VARCHAR(20),\n"
070: + " C_CITY VARCHAR(20),\n" + " C_STATE CHAR(2),\n"
071: + " C_ZIP CHAR(9),\n" + " C_PHONE CHAR(16),\n"
072: + " C_SINCE TIMESTAMP,\n" + " C_CREDIT CHAR(2),\n"
073: + " C_CREDIT_LIM DECIMAL(12, 2),\n"
074: + " C_DISCOUNT DECIMAL(4, 4),\n"
075: + " C_BALANCE DECIMAL(12, 2),\n"
076: + " C_YTD_PAYMENT DECIMAL(12, 2),\n"
077: + " C_PAYMENT_CNT DECIMAL(4),\n"
078: + " C_DELIVERY_CNT DECIMAL(4),\n"
079: + " C_DATA VARCHAR(500),\n"
080: + " PRIMARY KEY (C_W_ID, C_D_ID, C_ID))", // ,\n"
081: // + " FOREIGN KEY (C_W_ID, C_D_ID)\n"
082: // + " REFERENCES DISTRICT(D_W_ID, D_ID))",
083: "CREATE INDEX CUSTOMER_NAME ON CUSTOMER(C_LAST, C_D_ID, C_W_ID)",
084: "CREATE TABLE HISTORY(\n" + " H_C_ID INT,\n"
085: + " H_C_D_ID INT,\n" + " H_C_W_ID INT,\n"
086: + " H_D_ID INT,\n" + " H_W_ID INT,\n"
087: + " H_DATE TIMESTAMP,\n"
088: + " H_AMOUNT DECIMAL(6, 2),\n"
089: + " H_DATA VARCHAR(24))", // ,\n"
090: // + " FOREIGN KEY(H_C_W_ID, H_C_D_ID, H_C_ID)\n"
091: // + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID),\n"
092: // + " FOREIGN KEY(H_W_ID, H_D_ID)\n"
093: // + " REFERENCES DISTRICT(D_W_ID, D_ID))",
094: "CREATE TABLE ORDERS(\n" + " O_ID INT NOT NULL,\n"
095: + " O_D_ID INT NOT NULL,\n"
096: + " O_W_ID INT NOT NULL,\n" + " O_C_ID INT,\n"
097: + " O_ENTRY_D TIMESTAMP,\n"
098: + " O_CARRIER_ID INT,\n" + " O_OL_CNT INT,\n"
099: + " O_ALL_LOCAL DECIMAL(1),\n"
100: + " PRIMARY KEY(O_W_ID, O_D_ID, O_ID))", // ,\n"
101: // + " FOREIGN KEY(O_W_ID, O_D_ID, O_C_ID)\n"
102: // + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID))",
103: "CREATE INDEX ORDERS_OID ON ORDERS(O_ID)",
104: "CREATE TABLE NEW_ORDER(\n" + " NO_O_ID INT NOT NULL,\n"
105: + " NO_D_ID INT NOT NULL,\n"
106: + " NO_W_ID INT NOT NULL,\n"
107: + " PRIMARY KEY(NO_W_ID, NO_D_ID, NO_O_ID))", // ,\n"
108: // + " FOREIGN KEY(NO_W_ID, NO_D_ID, NO_O_ID)\n"
109: // + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID))",
110: "CREATE TABLE ITEM(\n" + " I_ID INT NOT NULL,\n"
111: + " I_IM_ID INT,\n" + " I_NAME VARCHAR(24),\n"
112: + " I_PRICE DECIMAL(5, 2),\n"
113: + " I_DATA VARCHAR(50),\n" + " PRIMARY KEY(I_ID))",
114: "CREATE TABLE STOCK(\n" + " S_I_ID INT NOT NULL,\n"
115: + " S_W_ID INT NOT NULL,\n"
116: + " S_QUANTITY DECIMAL(4),\n"
117: + " S_DIST_01 CHAR(24),\n"
118: + " S_DIST_02 CHAR(24),\n"
119: + " S_DIST_03 CHAR(24),\n"
120: + " S_DIST_04 CHAR(24),\n"
121: + " S_DIST_05 CHAR(24),\n"
122: + " S_DIST_06 CHAR(24),\n"
123: + " S_DIST_07 CHAR(24),\n"
124: + " S_DIST_08 CHAR(24),\n"
125: + " S_DIST_09 CHAR(24),\n"
126: + " S_DIST_10 CHAR(24),\n" + " S_YTD DECIMAL(8),\n"
127: + " S_ORDER_CNT DECIMAL(4),\n"
128: + " S_REMOTE_CNT DECIMAL(4),\n"
129: + " S_DATA VARCHAR(50),\n"
130: + " PRIMARY KEY(S_W_ID, S_I_ID))", // ,\n"
131: // + " FOREIGN KEY(S_W_ID)\n"
132: // + " REFERENCES WAREHOUSE(W_ID),\n"
133: // + " FOREIGN KEY(S_I_ID)\n" + " REFERENCES ITEM(I_ID))",
134: "CREATE TABLE ORDER_LINE(\n"
135: + " OL_O_ID INT NOT NULL,\n"
136: + " OL_D_ID INT NOT NULL,\n"
137: + " OL_W_ID INT NOT NULL,\n"
138: + " OL_NUMBER INT NOT NULL,\n"
139: + " OL_I_ID INT,\n"
140: + " OL_SUPPLY_W_ID INT,\n"
141: + " OL_DELIVERY_D TIMESTAMP,\n"
142: + " OL_QUANTITY DECIMAL(2),\n"
143: + " OL_AMOUNT DECIMAL(6, 2),\n"
144: + " OL_DIST_INFO CHAR(24),\n"
145: + " PRIMARY KEY (OL_W_ID, OL_D_ID, OL_O_ID, OL_NUMBER))", // ,\n"
146: // + " FOREIGN KEY(OL_W_ID, OL_D_ID, OL_O_ID)\n"
147: // + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID),\n"
148: // + " FOREIGN KEY(OL_SUPPLY_W_ID, OL_I_ID)\n"
149: // + " REFERENCES STOCK(S_W_ID, S_I_ID))",
150: "CREATE TABLE RESULTS(\n"
151: + " ID INT NOT NULL PRIMARY KEY,\n"
152: + " TERMINAL INT,\n" + " OPERATION INT,\n"
153: + " RESPONSE_TIME INT,\n"
154: + " PROCESSING_TIME INT,\n" + " KEYING_TIME INT,\n"
155: + " THINK_TIME INT,\n" + " SUCCESSFUL INT,\n"
156: + " NOW TIMESTAMP)" };
157:
158: public void init(Database db, int size) throws Exception {
159: this .db = db;
160:
161: random = new BenchCRandom();
162:
163: items = size * 10;
164: warehouses = 1;
165: districtsPerWarehouse = Math.max(1, size / 100);
166: customersPerDistrict = Math.max(1, size / 100);
167: ordersPerDistrict = Math.max(1, size / 1000);
168:
169: db.start(this , "Init");
170: db.openConnection();
171: load();
172: db.commit();
173: db.closeConnection();
174: db.end();
175:
176: // db.start(this, "Open/Close");
177: // db.openConnection();
178: // db.closeConnection();
179: // db.end();
180:
181: }
182:
183: private void load() throws Exception {
184: for (int i = 0; i < TABLES.length; i++) {
185: db.dropTable(TABLES[i]);
186: }
187: for (int i = 0; i < CREATE_SQL.length; i++) {
188: db.update(CREATE_SQL[i]);
189: }
190: db.setAutoCommit(false);
191: loadItem();
192: loadWarehouse();
193: loadCustomer();
194: loadOrder();
195: db.commit();
196: trace("load done");
197: }
198:
199: void trace(String s) {
200: action = s;
201: }
202:
203: void trace(int i, int max) {
204: db.trace(action, i, max);
205: }
206:
207: private void loadItem() throws Exception {
208: trace("load item");
209: boolean[] original = random.getBoolean(items, items / 10);
210: PreparedStatement prep = db
211: .prepare("INSERT INTO ITEM(I_ID, I_IM_ID, I_NAME, I_PRICE, I_DATA) "
212: + "VALUES(?, ?, ?, ?, ?)");
213: for (int id = 1; id <= items; id++) {
214: String name = random.getString(14, 24);
215: BigDecimal price = random.getBigDecimal(random.getInt(100,
216: 10000), 2);
217: String data = random.getString(26, 50);
218: if (original[id - 1]) {
219: data = random.replace(data, "original");
220: }
221: prep.setInt(1, id);
222: prep.setInt(2, random.getInt(1, 10000));
223: prep.setString(3, name);
224: prep.setBigDecimal(4, price);
225: prep.setString(5, data);
226: db.update(prep, "insertItem");
227: trace(id, items);
228: if (id % commitEvery == 0) {
229: db.commit();
230: }
231: }
232: }
233:
234: private void loadWarehouse() throws Exception {
235: trace("loading warehouses");
236: PreparedStatement prep = db
237: .prepare("INSERT INTO WAREHOUSE(W_ID, W_NAME, W_STREET_1, "
238: + "W_STREET_2, W_CITY, W_STATE, W_ZIP, W_TAX, W_YTD) "
239: + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
240: for (int id = 1; id <= warehouses; id++) {
241: String name = random.getString(6, 10);
242: String[] address = random.getAddress();
243: String street1 = address[0];
244: String street2 = address[1];
245: String city = address[2];
246: String state = address[3];
247: String zip = address[4];
248: BigDecimal tax = random.getBigDecimal(random
249: .getInt(0, 2000), 4);
250: BigDecimal ytd = new BigDecimal("300000.00");
251: prep.setInt(1, id);
252: prep.setString(2, name);
253: prep.setString(3, street1);
254: prep.setString(4, street2);
255: prep.setString(5, city);
256: prep.setString(6, state);
257: prep.setString(7, zip);
258: prep.setBigDecimal(8, tax);
259: prep.setBigDecimal(9, ytd);
260: db.update(prep, "insertWarehouse");
261: loadStock(id);
262: loadDistrict(id);
263: if (id % commitEvery == 0) {
264: db.commit();
265: }
266: }
267: }
268:
269: private void loadCustomer() throws Exception {
270: trace("load customers");
271: int max = warehouses * districtsPerWarehouse;
272: int i = 0;
273: for (int id = 1; id <= warehouses; id++) {
274: for (int districtId = 1; districtId <= districtsPerWarehouse; districtId++) {
275: loadCustomerSub(districtId, id);
276: trace(i++, max);
277: if (i % commitEvery == 0) {
278: db.commit();
279: }
280: }
281: }
282: }
283:
284: private void loadCustomerSub(int dId, int wId) throws Exception {
285: Timestamp timestamp = new Timestamp(System.currentTimeMillis());
286: PreparedStatement prepCustomer = db
287: .prepare("INSERT INTO CUSTOMER(C_ID, C_D_ID, C_W_ID, "
288: + "C_FIRST, C_MIDDLE, C_LAST, "
289: + "C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, "
290: + "C_PHONE, C_SINCE, C_CREDIT, "
291: + "C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_DATA, "
292: + "C_YTD_PAYMENT, C_PAYMENT_CNT, C_DELIVERY_CNT) "
293: + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
294: PreparedStatement prepHistory = db
295: .prepare("INSERT INTO HISTORY(H_C_ID, H_C_D_ID, H_C_W_ID, "
296: + "H_W_ID, H_D_ID, H_DATE, H_AMOUNT, H_DATA) "
297: + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
298: for (int cId = 1; cId <= customersPerDistrict; cId++) {
299: String first = random.getString(8, 16);
300: String middle = "OE";
301: String last;
302: if (cId < 1000) {
303: last = random.getLastname(cId);
304: } else {
305: last = random.getLastname(random.getNonUniform(255, 0,
306: 999));
307: }
308: String[] address = random.getAddress();
309: String street1 = address[0];
310: String street2 = address[1];
311: String city = address[2];
312: String state = address[3];
313: String zip = address[4];
314: String phone = random.getNumberString(16, 16);
315: String credit;
316: if (random.getInt(0, 1) == 0) {
317: credit = "GC";
318: } else {
319: credit = "BC";
320: }
321: BigDecimal discount = random.getBigDecimal(random.getInt(0,
322: 5000), 4);
323: BigDecimal balance = new BigDecimal("-10.00");
324: BigDecimal creditLim = new BigDecimal("50000.00");
325: String data = random.getString(300, 500);
326: BigDecimal ytdPayment = new BigDecimal("10.00");
327: int paymentCnt = 1;
328: int deliveryCnt = 1;
329: prepCustomer.setInt(1, cId);
330: prepCustomer.setInt(2, dId);
331: prepCustomer.setInt(3, wId);
332: prepCustomer.setString(4, first);
333: prepCustomer.setString(5, middle);
334: prepCustomer.setString(6, last);
335: prepCustomer.setString(7, street1);
336: prepCustomer.setString(8, street2);
337: prepCustomer.setString(9, city);
338: prepCustomer.setString(10, state);
339: prepCustomer.setString(11, zip);
340: prepCustomer.setString(12, phone);
341: prepCustomer.setTimestamp(13, timestamp);
342: prepCustomer.setString(14, credit);
343: prepCustomer.setBigDecimal(15, creditLim);
344: prepCustomer.setBigDecimal(16, discount);
345: prepCustomer.setBigDecimal(17, balance);
346: prepCustomer.setString(18, data);
347: prepCustomer.setBigDecimal(19, ytdPayment);
348: prepCustomer.setInt(20, paymentCnt);
349: prepCustomer.setInt(21, deliveryCnt);
350: db.update(prepCustomer, "insertCustomer");
351: BigDecimal amount = new BigDecimal("10.00");
352: String hData = random.getString(12, 24);
353: prepHistory.setInt(1, cId);
354: prepHistory.setInt(2, dId);
355: prepHistory.setInt(3, wId);
356: prepHistory.setInt(4, wId);
357: prepHistory.setInt(5, dId);
358: prepHistory.setTimestamp(6, timestamp);
359: prepHistory.setBigDecimal(7, amount);
360: prepHistory.setString(8, hData);
361: db.update(prepHistory, "insertHistory");
362: }
363: }
364:
365: private void loadOrder() throws Exception {
366: trace("load orders");
367: int max = warehouses * districtsPerWarehouse;
368: int i = 0;
369: for (int wId = 1; wId <= warehouses; wId++) {
370: for (int dId = 1; dId <= districtsPerWarehouse; dId++) {
371: loadOrderSub(dId, wId);
372: trace(i++, max);
373: }
374: }
375: }
376:
377: private void loadOrderSub(int dId, int wId) throws Exception {
378: Timestamp timestamp = new Timestamp(System.currentTimeMillis());
379: int[] orderid = random.getPermutation(ordersPerDistrict);
380: PreparedStatement prepOrder = db
381: .prepare("INSERT INTO ORDERS(O_ID, O_C_ID, O_D_ID, O_W_ID, "
382: + "O_ENTRY_D, O_CARRIER_ID, O_OL_CNT, O_ALL_LOCAL) "
383: + "VALUES(?, ?, ?, ?, ?, ?, ?, 1)");
384: PreparedStatement prepNewOrder = db
385: .prepare("INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) "
386: + "VALUES (?, ?, ?)");
387: PreparedStatement prepLine = db
388: .prepare("INSERT INTO ORDER_LINE("
389: + "OL_O_ID, OL_D_ID, OL_W_ID, OL_NUMBER, "
390: + "OL_I_ID, OL_SUPPLY_W_ID, OL_QUANTITY, OL_AMOUNT, "
391: + "OL_DIST_INFO, OL_DELIVERY_D)"
392: + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)");
393: for (int oId = 1, i = 0; oId <= ordersPerDistrict; oId++) {
394: int cId = orderid[oId - 1];
395: int carrierId = random.getInt(1, 10);
396: int olCnt = random.getInt(5, 15);
397: prepOrder.setInt(1, oId);
398: prepOrder.setInt(2, cId);
399: prepOrder.setInt(3, dId);
400: prepOrder.setInt(4, wId);
401: prepOrder.setTimestamp(5, timestamp);
402: prepOrder.setInt(7, olCnt);
403: if (oId <= 2100) {
404: prepOrder.setInt(6, carrierId);
405: } else {
406: // the last 900 orders have not been delivered
407: prepOrder.setNull(6, Types.INTEGER);
408: prepNewOrder.setInt(1, oId);
409: prepNewOrder.setInt(2, dId);
410: prepNewOrder.setInt(3, wId);
411: db.update(prepNewOrder, "newNewOrder");
412: }
413: db.update(prepOrder, "insertOrder");
414: for (int ol = 1; ol <= olCnt; ol++) {
415: int id = random.getInt(1, items);
416: int supplyId = wId;
417: int quantity = 5;
418: String distInfo = random.getString(24);
419: BigDecimal amount;
420: if (oId < 2101) {
421: amount = random.getBigDecimal(0, 2);
422: } else {
423: amount = random.getBigDecimal(random.getInt(0,
424: 1000000), 2);
425: }
426: prepLine.setInt(1, oId);
427: prepLine.setInt(2, dId);
428: prepLine.setInt(3, wId);
429: prepLine.setInt(4, ol);
430: prepLine.setInt(5, id);
431: prepLine.setInt(6, supplyId);
432: prepLine.setInt(7, quantity);
433: prepLine.setBigDecimal(8, amount);
434: prepLine.setString(9, distInfo);
435: db.update(prepLine, "insertOrderLine");
436: if (i++ % commitEvery == 0) {
437: db.commit();
438: }
439: }
440: }
441: }
442:
443: private void loadStock(int wId) throws Exception {
444: trace("load stock (warehouse " + wId + ")");
445: boolean[] original = random.getBoolean(items, items / 10);
446: PreparedStatement prep = db
447: .prepare("INSERT INTO STOCK(S_I_ID, S_W_ID, S_QUANTITY, "
448: + "S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05, "
449: + "S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10, "
450: + "S_DATA, S_YTD, S_ORDER_CNT, S_REMOTE_CNT) "
451: + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
452: for (int id = 1; id <= items; id++) {
453: int quantity = random.getInt(10, 100);
454: String dist01 = random.getString(24);
455: String dist02 = random.getString(24);
456: String dist03 = random.getString(24);
457: String dist04 = random.getString(24);
458: String dist05 = random.getString(24);
459: String dist06 = random.getString(24);
460: String dist07 = random.getString(24);
461: String dist08 = random.getString(24);
462: String dist09 = random.getString(24);
463: String dist10 = random.getString(24);
464: String data = random.getString(26, 50);
465: if (original[id - 1]) {
466: data = random.replace(data, "original");
467: }
468: prep.setInt(1, id);
469: prep.setInt(2, wId);
470: prep.setInt(3, quantity);
471: prep.setString(4, dist01);
472: prep.setString(5, dist02);
473: prep.setString(6, dist03);
474: prep.setString(7, dist04);
475: prep.setString(8, dist05);
476: prep.setString(9, dist06);
477: prep.setString(10, dist07);
478: prep.setString(11, dist08);
479: prep.setString(12, dist09);
480: prep.setString(13, dist10);
481: prep.setString(14, data);
482: prep.setInt(15, 0);
483: prep.setInt(16, 0);
484: prep.setInt(17, 0);
485: db.update(prep, "insertStock");
486: if (id % commitEvery == 0) {
487: db.commit();
488: }
489: trace(id, items);
490: }
491: }
492:
493: private void loadDistrict(int wId) throws Exception {
494: BigDecimal ytd = new BigDecimal("300000.00");
495: int nextId = 3001;
496: PreparedStatement prep = db
497: .prepare("INSERT INTO DISTRICT(D_ID, D_W_ID, D_NAME, "
498: + "D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, "
499: + "D_TAX, D_YTD, D_NEXT_O_ID) "
500: + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
501: for (int dId = 1; dId <= districtsPerWarehouse; dId++) {
502: String name = random.getString(6, 10);
503: String[] address = random.getAddress();
504: String street1 = address[0];
505: String street2 = address[1];
506: String city = address[2];
507: String state = address[3];
508: String zip = address[4];
509: BigDecimal tax = random.getBigDecimal(random
510: .getInt(0, 2000), 4);
511: prep.setInt(1, dId);
512: prep.setInt(2, wId);
513: prep.setString(3, name);
514: prep.setString(4, street1);
515: prep.setString(5, street2);
516: prep.setString(6, city);
517: prep.setString(7, state);
518: prep.setString(8, zip);
519: prep.setBigDecimal(9, tax);
520: prep.setBigDecimal(10, ytd);
521: prep.setInt(11, nextId);
522: db.update(prep, "insertDistrict");
523: trace(dId, districtsPerWarehouse);
524: }
525: }
526:
527: public void runTest() throws Exception {
528: db.start(this , "Transactions");
529: db.openConnection();
530: for (int i = 0; i < 70; i++) {
531: BenchCThread process = new BenchCThread(db, this , random, i);
532: process.process();
533: }
534: db.closeConnection();
535: db.end();
536:
537: db.openConnection();
538: BenchCThread process = new BenchCThread(db, this , random, 0);
539: process.process();
540: db.logMemory(this , "Memory Usage");
541: db.closeConnection();
542: }
543:
544: public String getName() {
545: return "BenchC";
546: }
547:
548: }
|