title: How do I implement getConnection() in DataSource in Java?
body: <p>I'm reading up on DataSource, <a href="http://download.oracle.com/javase/1.4.2/docs/guide/jdbc/getstart/datasource.html" rel="nofollow">here</a>, and trying to implement it in my own little project by using a simple file as my "data source".  I've created a class that is pretty simple at the moment...</p>
  
  <pre><code>public class QueueData implements DataSource { ... }
  </code></pre>
  
  <p>though the reason it is simple is because I haven't been able to find a resource that explains how the implemented methods should work.  Everyone seems to just list the initialization of a context and a magical getConnection() call, like so.</p>
  
  <pre><code>    Context ctx = new InitialContext(env1);
      DataSource ds = (DataSource)ctx.lookup("jdbc/mydatasource");
      Connection conn = ds.getConnection(); // Magical method!
  </code></pre>
  
  <p>But can one of you actually give me an example of what the code inside getConnection() should look like?</p>