Ejemplo n.º 1
0
  public void setValueAt(Object value, int row, int col) { // are you editing?
    /*prepare the query*/
    /*you have to change the query to adapt it to your table*/
    if (col == 0) kolon = "english";
    if (col == 1) kolon = "turkish";
    String s =
        "update soz set "
            + kolon
            + " = '"
            + (String) value
            + "' where "
            + kolon
            + " = '"
            + ((String[]) cache.elementAt(row))[col]
            + "'";
    System.out.println(s);
    /*excecute the query*/
    try {
      statement.execute(s);
    } catch (Exception e) {
      System.out.println("Could not updated");
    }

    ((String[]) cache.elementAt(row))[col] = (String) value;
    fireTableCellUpdated(row, col); // also update the table
  }
Ejemplo n.º 2
0
 public boolean isValidUser() throws SQLException {
   CreateJDBCConnection jdbc = new CreateJDBCConnection();
   Statement stmt = jdbc.getStatement();
   stmt.execute("use jana;");
   String sqlQuery =
       "select password from user_details where idno = '" + nameText.getText() + "';";
   ResultSet rs = stmt.executeQuery(sqlQuery);
   while (rs.next()) {
     if (rs.getString("password").equals(passText.getText())) return true;
   }
   return false;
 }
Ejemplo n.º 3
0
 /**
  * _more_
  *
  * @param sql _more_
  * @return _more_
  * @throws SQLException _more_
  */
 private Statement evaluate(String sql) throws SQLException {
   System.err.println("EVAL: " + sql);
   Statement stmt = getConnection().createStatement();
   stmt.execute(sql);
   return stmt;
 }
  private void execute() {

    gResult.clear();

    String sCmd = null;

    if (4096 <= ifHuge.length()) {
      sCmd = ifHuge;
    } else {
      sCmd = txtCommand.getText();
    }

    if (sCmd.startsWith("-->>>TEST<<<--")) {
      testPerformance();

      return;
    }

    String g[] = new String[1];

    try {
      lTime = System.currentTimeMillis();

      sStatement.execute(sCmd);

      int r = sStatement.getUpdateCount();

      if (r == -1) {
        formatResultSet(sStatement.getResultSet());
      } else {
        g[0] = "update count";

        gResult.setHead(g);

        g[0] = "" + r;

        gResult.addRow(g);
      }

      lTime = System.currentTimeMillis() - lTime;

      addToRecent(txtCommand.getText());
      gResult.fireTableChanged(null);
    } catch (SQLException e) {
      lTime = System.currentTimeMillis() - lTime;
      g[0] = "SQL Error";

      gResult.setHead(g);

      String s = e.getMessage();

      s += " / Error Code: " + e.getErrorCode();
      s += " / State: " + e.getSQLState();
      g[0] = s;

      gResult.addRow(g);
      gResult.fireTableChanged(null);
    }

    updateResult();
    System.gc();
  }