title: can we create a common database class in java
body: <p>i want to know if we can create a common database class same like we create a connection class and just call getConnection when we need connection to be established.<br/>
  Basically, i want a database manager class which can handle database operation irrespective of tablename, columncount,etc.<br/>
  tablename, columnname, values to be inserted would be passed as parameters from servlet.
  that way, i can reduce duplication of code. m tryin to make a simple mvc application using jsp-servlets. my database is mysql. i dont know struts, spring, hibernate.<br/></p>
  
  <p>For Example, servlet code will call(<code>databaseManager</code> is the class name.) :</p>
  
  <pre><code>int count=databaseManager.getCount("tableName", "columnName", "value");
  </code></pre>
  
  <p>and in <code>databaseManager</code>, there will be a function -</p>
  
  <pre><code>public static int getCount(String tableName, String[] arrC, objectArray[] arrV)
  {}
  </code></pre>
  
  <p>similarly, for other functions.
  i googled and found out that it could be done using metadata.
  but i dont know how to use it.
  it would be helpful if u could post code of one function for similar approach.</p>