コード例 #1
0
 private void jButton2ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
   // TODO add your handling code here:
   Stock s = new Stock();
   s.setVisible(true);
   setVisible(false);
   dispose();
 } // GEN-LAST:event_jButton2ActionPerformed
コード例 #2
0
ファイル: LoadData.java プロジェクト: andl/benchmarkSQL
  static int loadStock(int whseKount, int itemKount) {

    int k = 0;
    int t = 0;
    int randPct = 0;
    int len = 0;
    int startORIGINAL = 0;

    try {

      now = new java.util.Date();
      t = (whseKount * itemKount);
      System.out.println("\nStart Stock Load for " + t + " units @ " + now + " ...");

      if (outputFiles == true) {
        out = new PrintWriter(new FileOutputStream(fileLocation + "stock.csv"));
        System.out.println("\nWriting Stock file to: " + fileLocation + "stock.csv");
      }

      Stock stock = new Stock();

      for (int i = 1; i <= itemKount; i++) {

        for (int w = 1; w <= whseKount; w++) {

          stock.s_i_id = i;
          stock.s_w_id = w;
          stock.s_quantity = jTPCCUtil.randomNumber(10, 100, gen);
          stock.s_ytd = 0;
          stock.s_order_cnt = 0;
          stock.s_remote_cnt = 0;

          // s_data
          randPct = jTPCCUtil.randomNumber(1, 100, gen);
          len = jTPCCUtil.randomNumber(26, 50, gen);
          if (randPct > 10) {
            // 90% of time i_data isa random string of length [26 .. 50]
            stock.s_data = jTPCCUtil.randomStr(len);
          } else {
            // 10% of time i_data has "ORIGINAL" crammed somewhere in middle
            startORIGINAL = jTPCCUtil.randomNumber(2, (len - 8), gen);
            stock.s_data =
                jTPCCUtil.randomStr(startORIGINAL - 1)
                    + "ORIGINAL"
                    + jTPCCUtil.randomStr(len - startORIGINAL - 9);
          }

          stock.s_dist_01 = jTPCCUtil.randomStr(24);
          stock.s_dist_02 = jTPCCUtil.randomStr(24);
          stock.s_dist_03 = jTPCCUtil.randomStr(24);
          stock.s_dist_04 = jTPCCUtil.randomStr(24);
          stock.s_dist_05 = jTPCCUtil.randomStr(24);
          stock.s_dist_06 = jTPCCUtil.randomStr(24);
          stock.s_dist_07 = jTPCCUtil.randomStr(24);
          stock.s_dist_08 = jTPCCUtil.randomStr(24);
          stock.s_dist_09 = jTPCCUtil.randomStr(24);
          stock.s_dist_10 = jTPCCUtil.randomStr(24);

          k++;
          if (outputFiles == false) {
            stckPrepStmt.setLong(1, stock.s_i_id);
            stckPrepStmt.setLong(2, stock.s_w_id);
            stckPrepStmt.setDouble(3, stock.s_quantity);
            stckPrepStmt.setDouble(4, stock.s_ytd);
            stckPrepStmt.setLong(5, stock.s_order_cnt);
            stckPrepStmt.setLong(6, stock.s_remote_cnt);
            stckPrepStmt.setString(7, stock.s_data);
            stckPrepStmt.setString(8, stock.s_dist_01);
            stckPrepStmt.setString(9, stock.s_dist_02);
            stckPrepStmt.setString(10, stock.s_dist_03);
            stckPrepStmt.setString(11, stock.s_dist_04);
            stckPrepStmt.setString(12, stock.s_dist_05);
            stckPrepStmt.setString(13, stock.s_dist_06);
            stckPrepStmt.setString(14, stock.s_dist_07);
            stckPrepStmt.setString(15, stock.s_dist_08);
            stckPrepStmt.setString(16, stock.s_dist_09);
            stckPrepStmt.setString(17, stock.s_dist_10);
            stckPrepStmt.addBatch();
            if ((k % configCommitCount) == 0) {
              long tmpTime = new java.util.Date().getTime();
              String etStr =
                  "  Elasped Time(ms): "
                      + ((tmpTime - lastTimeMS) / 1000.000)
                      + "                    ";
              System.out.println(etStr.substring(0, 30) + "  Writing record " + k + " of " + t);
              lastTimeMS = tmpTime;
              stckPrepStmt.executeBatch();
              stckPrepStmt.clearBatch();
              transCommit();
            }
          } else {
            String str = "";
            str = str + stock.s_i_id + ",";
            str = str + stock.s_w_id + ",";
            str = str + stock.s_quantity + ",";
            str = str + stock.s_ytd + ",";
            str = str + stock.s_order_cnt + ",";
            str = str + stock.s_remote_cnt + ",";
            str = str + stock.s_data + ",";
            str = str + stock.s_dist_01 + ",";
            str = str + stock.s_dist_02 + ",";
            str = str + stock.s_dist_03 + ",";
            str = str + stock.s_dist_04 + ",";
            str = str + stock.s_dist_05 + ",";
            str = str + stock.s_dist_06 + ",";
            str = str + stock.s_dist_07 + ",";
            str = str + stock.s_dist_08 + ",";
            str = str + stock.s_dist_09 + ",";
            str = str + stock.s_dist_10;
            out.println(str);

            if ((k % configCommitCount) == 0) {
              long tmpTime = new java.util.Date().getTime();
              String etStr =
                  "  Elasped Time(ms): "
                      + ((tmpTime - lastTimeMS) / 1000.000)
                      + "                    ";
              System.out.println(etStr.substring(0, 30) + "  Writing record " + k + " of " + t);
              lastTimeMS = tmpTime;
            }
          }
        } // end for [w]
      } // end for [i]

      long tmpTime = new java.util.Date().getTime();
      String etStr =
          "  Elasped Time(ms): " + ((tmpTime - lastTimeMS) / 1000.000) + "                    ";
      System.out.println(etStr.substring(0, 30) + "  Writing final records " + k + " of " + t);
      lastTimeMS = tmpTime;
      if (outputFiles == false) {
        stckPrepStmt.executeBatch();
      }
      transCommit();

      now = new java.util.Date();
      System.out.println("End Stock Load @  " + now);

    } catch (SQLException se) {
      System.out.println(se.getMessage());
      transRollback();

    } catch (Exception e) {
      e.printStackTrace();
      transRollback();
    }

    return (k);
  } // end loadStock()