title: How to provide code for updating multiple columns with JDBC?
body: <p>I am developing a java application that is working with a MySql database. This is going to be used by a colleague of mine, as an external jar.  </p>
  
  <p>My problem is that they need to update certain columns of the table. Is there a way to provide a method where they could choose which column they want to update?</p>
  
  <p>The alternative I know is to create a different method for each column, having for example</p>
  
  <pre><code>Update.updateName(String name);
  Update.updateAge(int age);
  ....
  </code></pre>
  
  <p>That would take a lot of effort to write, since there a more than 20 columns available.</p>
  
  <p><strong>EDIT</strong>  </p>
  
  <p>Ok, it seems that I wasn't clear :)</p>
  
  <p>Update is just a class that handles the database update. Nothing of importance really.  </p>
  
  <p>So, to rephrase, I need a way to handle updates to a table with multiple columns.   </p>
  
  <p>My code is going to be used by others, so I need a way to use some method that would "force" them to choose a column (or a number of them) from the available columns, instead of letting them insert as free text. </p>
  
  <p>Let's say I have a table like so</p>
  
  <pre><code>name    varchar(50)
  age     int(3)
  address varchar(300)
  </code></pre>
  
  <p>If I just had these three columns I would do</p>
  
  <pre><code>public class Update{
    public void updateName(String name,int id){
       //connect to mysql and update name
    }
  
    public void updateAge(int age,int id){
       //connect to mysql and update age
    }
  
    public void updateAddress(String address,int id){
       //connect to mysql and update address
    }
  }
  </code></pre>
  
  <p>and my colleagues would do  </p>
  
  <pre><code>Update update =new Update();
  update.updateName("newName",1);
  update.updateAge(20,1);
  .....
  </code></pre>
  
  <p>As I mention before, that would take alot of effort, because of the size of my table. Is there a way to "load" the column names on my code and allow the user of the jar library to choose one from that list? (since this is a library it will not be executed in advance in order to get the names from the database)</p>