title: How do I manually configure a DataSource in Java?
body: <p>I'm trying to follow Sun's JDBC tutorial at <a href="http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html" rel="noreferrer">http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html</a></p>
  
  <p>It gives the following example code:</p>
  
  <pre><code>DataSource ds = (DataSource) org.apache.derby.jdbc.ClientDataSource()
  ds.setPort(1527);
  ds.setHost("localhost");
  ds.setUser("APP")
  ds.setPassword("APP");
  
  Connection con = ds.getConnection();
  </code></pre>
  
  <p>This code doesn't compile because the <code>DataSource</code> interface has none of these methods, except for the <code>getConnection()</code> method invoked last.  </p>
  
  <p>(Here's the javadoc:  <a href="http://java.sun.com/javase/6/docs/api/javax/sql/DataSource.html" rel="noreferrer">http://java.sun.com/javase/6/docs/api/javax/sql/DataSource.html</a>)</p>
  
  <p>What am I missing?</p>
  
  <p><strong>Edit:</strong>
  I'm actually trying to connect to MySQL (<code>com.mysql.jdbc</code>) and I can't find the javadoc for that.  I'll accept an answer that points me to either: </p>
  
  <p>1) documentation for <code>com.mysql.jdbc</code> regarding a <code>DataSource</code> that I can understand, or</p>
  
  <p>2) gives an example to follow for what the tutorial's code <em>should</em> be, for any database.</p>