Exemplo n.º 1
0
 public void insert(Object[] obj) {
   try {
     DefaultTableModel dtt = (DefaultTableModel) getModel();
     dtt.addRow(obj);
     dataBaru.add(getModel().getRowCount() - 1);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 2
0
  private ConnectionPool(int initCon, int maxCon) throws Exception {
    this.initCon = initCon;
    this.maxCon = maxCon;

    pool = new Vector();
    for (int i = 0; i < initCon; i++) {
      pool.add(createConnection());
    }
  }
Exemplo n.º 3
0
  // </editor-fold>
  // <editor-fold defaultstate="collapsed" desc="Select Table">
  public void selectTabel(DefaultTableModel tableM) {
    setModelTable(tableM);
    try {
      dataAsli = new Vector();
      rowSet.setCommand(sql);
      rowSet.execute();
      DefaultTableModel dtm = (DefaultTableModel) getModel();
      int i = 0;

      // tipeKolom =
      // untukASIU#noKolomJtable#tipeKolomJTable#namaKolomDB#tipeKolom#atributKolom#nilaiKolom
      // tipeKolom = boolean, Date, String, combo, Int, Numeric
      while (rowSet.next()) {
        Object[] dede = new Object[selectKolom.size()];
        for (int ii = 0; ii < selectKolom.size(); ii++) {
          String temp = selectKolom.get(ii + "");
          String data[] = temp.split("#");
          int no = 0;
          try {
            no = Integer.parseInt(data[1].trim());
          } catch (Exception e) {
            no = 0;
          }
          if (data[0].trim().toLowerCase().contains("s")) {
            if (data[2].trim().toLowerCase().equals("boolean")) {
              boolean value = false;
              if (data[4].trim().toLowerCase().equals("int")) {
                if (rowSet.getInt(data[3].trim()) == Integer.parseInt(data[5].trim())) {
                  value = true;
                } else {
                  value = false;
                }
              } else {
                if (rowSet.getString(data[3].trim()).equals(data[5].trim())) {
                  value = true;
                } else {
                  value = false;
                }
              }
              dede[no] = value;
            } else if (data[2].trim().toLowerCase().equals("date")) {
              java.util.Date value = new java.util.Date();
              if (data[4].equals("dd-MM-yyyy")) {
                value = Function.dateStringToDate(rowSet.getString(data[3].trim()));
              } else if (data[4].equals("MM-yyyy")) {
                value = Function.stringToMonth(rowSet.getString(data[3].trim()));
              } else if (data[4].equals("yyyy")) {
                value = Function.yearToDate(rowSet.getString(data[3].trim()));
              }
              dede[no] = value;
            } else if (data[2].trim().toLowerCase().equals("string")
                || data[2].trim().toLowerCase().equals("combo")
                || data[2].trim().toLowerCase().equals("numeric")) {
              String value = "";
              if (data[4].trim().toLowerCase().equals("int")) {
                value = rowSet.getLong(data[3].trim()) + "";
              } else {
                value = rowSet.getString(data[3].trim());
              }
              dede[no] = value;
            }
          }
        }
        dtm.addRow(dede);
        dataAsli.add(i);
        i++;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 4
0
  public synchronized void releaseConnection(Connection conn) {
    pool.add(conn);

    users--;
    notifyAll();
  }