title: Update query in java jdbc gives run time error
body: <p>This is a program for updating a table using <a href="/questions/tagged/jdbc" class="post-tag" title="show questions tagged &#39;jdbc&#39;" rel="tag">jdbc</a> and it compiled successfully.</p>
  
  <p>But at runtime gives error.</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  
  public class UpdateProfile {
  
      public static void main(String args[]) {
  
          String fname = "ranjesh";
          String lname = "singh";
          String phone = "9870899645";
          String address = "ghz";
          String email = "sarwesh1206@gmail.com";
  
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/XE", "system", "oracle");
  
              //system is username and oracle is password
              //userinfo is name of table.
  
              String query = "UPDATE userinfo set fname = ? ,lname=?,mobile=?,address=? where email = ? ";
              PreparedStatement pstmt = con.prepareStatement(query);
  
              pstmt.setString(1, fname); // set input parameter 1
              pstmt.setString(2, lname);
              pstmt.setString(3, phone);
              pstmt.setString(4, address);
              pstmt.setString(5, email);
  
              // set input parameter 2
  
              pstmt.executeUpdate(); // execute update statement
              con.commit();
              con.close();
              System.out.print("success");
  
          } catch (Exception ex) {
              System.out.print("error occurred");
          }
      }
  }
  </code></pre>
  
  <p>Schema of table userinfo:</p>
  
  <p><a href="https://i.stack.imgur.com/NtdxE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NtdxE.png" alt="schema of table userinfo"></a></p>