title: java.sql.SQLException: Can not issue executeUpdate() or executeLargeUpdate() for SELECTs
body: <p>I am trying register page, if email exits already it should get alert message, for this below is my some part of the code, i am using <code>executeQuery</code> for Select query but still i am getting error:</p>
  
  <blockquote>
    <p>java.sql.SQLException: Can not issue executeUpdate() or executeLargeUpdate() for SELECTs</p>
  </blockquote>
  
  <p>java code:</p>
  
  <pre><code>Class.forName("com.mysql.jdbc.Driver");
              Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/xxxx", "root","root");
              PreparedStatement ps=cn.prepareStatement("select * from Register where email=?");
              ps.setString(1, email);
              ResultSet rs=ps.executeQuery();
  
              if(rs.next())
              {
                  out.println("&lt;script type=\"text/javascript\"&gt;");
                     out.println("alert('Email already Exists Please Try with New Email');");
                     out.println("location='index.html';");
                     out.println("&lt;/script&gt;");
              }
              else{
  
                     PreparedStatement ps1 = cn.prepareStatement("insert into Register values(?,?,?,?,?)");
                                  ps1.setString(1, name);
                                  ps1.setString(2, email);
                                  ps1.setString(3, mobile);
                                  ps1.setString(4, password);
                                  ps1.setString(5, conform_password);
  
                                  int i = ps.executeUpdate();
                                  if (i != 0) {
                                      response.sendRedirect("index.html");
                                  } else {
                                      out.println("Some Thing went wrong. Try Again...");
                                  }
  
              }
          }
  </code></pre>