title: Java Connection Pool implementation
body: <p>can you look at my connection pool if it is a possible way to implement it?</p>
  
  <pre><code>public class ConnectionPool {
      private static List&lt;DBConnection&gt; pool = null;
      private static int available = 0;
      private ConnectionPool() {}
  
      public static DBConnection getConnection() {
          if (pool == null) {
               pool = new ArrayList&lt;DBConnection&gt;();
               for (int i = 0; i &lt; 3; i++) {
                   try {
                      pool.add(new DBConnection());
                      available++;
                  } catch (SQLException e) {
                      e.printStackTrace();
                  }
               }
          }
          if (pool.size() &gt; 0) {
              available--;
              return pool.remove(available);
          } else {
              return null;
          }
      }
  
      public static void returnConnection(DBConnection c) {
          pool.add(c);
          available++;
      }
  }
  </code></pre>
  
  <p>I'm using only one array and the client should ask the connection pool for a connection use it and then return it to the connection pool.</p>
  
  <pre><code>  Connection connection = ConnectionPool.getConnection();
    connection.execute("insert into users values('"+user.getUsername()+"', '"+user.getPassword()+"', '"+user.getGroup()+"', '"+banned+"', '"+broker+admin+sharehodler+company+"')");      
    ConnectionPool.returnConnection(connection);
    connection = null;
  </code></pre>
  
  <p>Please I need feedback on this implementation. Thank you</p>