Beispiel #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
  }
  /** Method declaration Adjust this method for large strings...ie multi megabtypes. */
  void execute() {

    String sCmd = null;

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

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

      return;
    }

    String g[] = new String[1];

    lTime = System.currentTimeMillis();

    try {
      sStatement.execute(sCmd);

      lTime = System.currentTimeMillis() - lTime;

      int r = sStatement.getUpdateCount();

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

        gResult.setHead(g);

        g[0] = String.valueOf(r);

        gResult.addRow(g);
      }

      addToRecent(txtCommand.getText());
    } 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);
    }

    updateResult();
    System.gc();
  }
Beispiel #3
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;
 }
Beispiel #4
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;
 }