title: how to do connection pooling in java?
body: <p>I am trying to understand <code>connection pooling in java</code>, i am using <code>jsp, servlet and tomcat 6 server</code> in my application. I have written the following code in a <code>java class dbconnection.java</code>:</p>
  
  <p>I am using type 4 jdbc connection with oracle 10g EE in windows Xp OS</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
      public class dbconnection {   
       public Connection con = null;    
        public Connection getConnection() throws Exception, SQLException
         {
           try
             {
            Class.forName("oracle.jdbc.driver.OracleDriver");
             con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:abc","abc", "abc");           
             }
             catch(Exception e)
             {          
             }
          return con;
          }
      public void removeConnection() throws SQLException
    {
      con.close();
    }
   }
  </code></pre>
  
  <p>Then i am retriving <code>connection</code> in servlet as follows:</p>
  
  <pre><code>try{
   dbconnection db= new dbconnection();
  
   Connection con=db.getConnection();
   }
   catch(Exception e){
   } 
  finally{
   db.removeConnection();//removes connection
  }
  </code></pre>
  
  <p>Is it <code>connection pooling</code> or some configuration is required in <code>tomcat server</code> or something else?</p>