title: Unable to update column values in mysql using java?
body: <p>I have created a table in mysql with one column "Sno". And inserted with 1 to 10 in column "Sno". I want to update columns values according to Sno, but am unable to do it. please help me. Thank you.</p>
  
  <p>Here is what my code.</p>
  
  <pre><code>int o=2,q=0;
  ResultSet rs = st7.executeQuery("select * from  table");
  ResultSetMetaData metadata = rs.getMetaData();//here is columns are added dynamically,So that is metadata is needed.
  
  BufferedReader br1 = new BufferedReader(new FileReader(f1));//here f1 is csv file path.
  
  while ((line1 = br1.readLine()) != null) {
  
      String[] splits = line1.split(",");//splitting line by ',' and storing into array.
  
      n1 = splits.length;
  
      for (m = 0; m &lt; n1; m++) {
  
          st8.executeUpdate("UPDATE table SET " + metadata.getColumnName(o) + "='" + splits[m] + "' WHERE Sno='"+q+"'");
          o++;
      }
  
      q++;
      out.println("&lt;br&gt;");
  }
  </code></pre>
  
  <p>Table structure</p>
  
  <pre><code>+--------+--------+--------+--------+---------+-----------+
  |Sno     | col1   | col2   | col3   | col4    | col5      | 
  +--------+--------+--------+--------+---------+-----------+
  | 0      |  NULL  | NULL   | NULL   | NULL    |  NULL     |
  +--------+--------+--------+--------+---------+-----------+
  | 1      | NULL   | NULL   | NULL   | NULL    | NULL      |
  </code></pre>