title: Change password program in java using netbeans
body: <p>After all the fuss I used JAVA DB and now using apache Derby client driver to use and after finally entering my database i have a new problem</p>
  
  <pre><code> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      String uname = jTextField1.getText();
      String strpass = jPasswordField1.getText();
      String newpass = jPasswordField2.getText();
      String conpass = jPasswordField3.getText();
  
      try
      {
      DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
      }
      catch(SQLException ex1)
      {
          ex1.printStackTrace();
      }
  
        try      
      {
  
          Class.forName("org.apache.derby.jdbc.ClientDriver");
      }
      catch(ClassNotFoundException ex)
      {
          ex.printStackTrace();
      }
      try
      {
          Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/niiitusers");
          Statement st = con.createStatement();
          ResultSet rs = st.executeQuery("Select * from app.userlogin");
          while(rs.next())
          {
              String usrname = rs.getString("username");
              String passwd = rs.getString("password");
              if(uname.equals(usrname) &amp;&amp; strpass.equals(passwd))
              {
  
                  if(newpass.equals(conpass))
                  {
                      Statement st1 = con.createStatement();
                      ResultSet i = st1.executeQuery("UPDATE app.userlogin SET password='newpass' where username='usname'");//query i am using to update the password
                      JOptionPane.showMessageDialog(null, "PASSWORD UPDATE SUCCESSFUL");
  
                  }
  
                  else
                  {
                      JOptionPane.showMessageDialog(null, "PLEASE CONFIRM PASSWORD");
                  }}
              else if(uname.equals("") &amp;&amp; strpass.equals("") &amp;&amp; newpass.equals(""))
              {
                  JOptionPane.showMessageDialog(null, "PLEASE ENTER ALL INFORMATION");
              }
              else
              {
                  JOptionPane.showMessageDialog(null, "USERNAME NOT FOUND");
              }
              st.close();
  
              con.close();
          }
  
      }
              catch(SQLException e)
              {
                  e.printStackTrace();
              }
  
  
  
  }                                        
  
  java.sql.SQLException: executeQuery method can not be used for update.
  at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
  at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
  at org.apache.derby.client.am.Statement.executeQuery(Unknown Source)
  </code></pre>
  
  <p>Its not performing the update operation. I am not sure where the problem is </p>