title: Using DataSource to connect to SQLite with (Xerial) sqlite-jdbc driver
body: <p><a href="http://docs.oracle.com/javase/tutorial/jdbc/overview/index.html" rel="noreferrer">Java Tutorial</a> says there are 2 ways to connect to database thru JDBC: with <strong>DriverManager</strong> class (old, not recommended) and with <strong>DataSource</strong> class.</p>
  
  <p>I undestand how to do it with DriverManager:</p>
  
  <pre><code>Connection con = DriverManager.getConnection("jdbc:sqlite:mytest.db");
  ...
  </code></pre>
  
  <p><strong>But I cannot find how to use DataSource for SQLite thru JDBC. Does SQLite (or JDBC driver providers for it, I don't know how to call it correctly) support using DataSource at all?</strong></p>
  
  <p>I am using <a href="https://github.com/xerial/sqlite-jdbc" rel="noreferrer">xerial/sqlite-jdbc</a> driver to use SQLite from java (<a href="https://github.com/xerial/sqlite-jdbc" rel="noreferrer">https://github.com/xerial/sqlite-jdbc</a>)</p>
  
  <p>My best guess is that I shall use org.sqlite.SQLiteDataSource class (it comes in sqlite-jdbc-3.15.1.jar for Xerial sqlite-jdbc driver), but how? And is it so? I also guess, that how to do it shall be in Xerial driver docs, but they give only example of how to connect using DriverManager. </p>
  
  <p><strong>So I am asking kind help of guru to confirm that <a href="https://github.com/xerial/sqlite-jdbc" rel="noreferrer">this</a> Xerial driver/jar doesn't support DataSource syntax, or to give example how to do it, or to suggest alternative driver with DataSource support (for SQLite from Java), or advice otherwise...</strong></p>
  
  <p><a href="http://docs.oracle.com/javase/tutorial/jdbc/overview/index.html" rel="noreferrer">Java Tutorial</a></p>
  
  <blockquote>
    <p>JDBC Driver Manager —  The JDBC DriverManager class defines objects
    which can connect Java applications to a JDBC driver. DriverManager
    has traditionally been the backbone of the JDBC architecture. It is
    quite small and simple.</p>
    
    <p>The Standard Extension packages javax.naming and javax.sql let you use
    a DataSource object registered with a Java Naming and Directory
    Interface™ (JNDI) naming service to establish a connection with a data
    source. You can use either connecting mechanism, but using a
    DataSource object is recommended whenever possible.</p>
  </blockquote>