title: SQLite JDBC PRAGMA setting
body: <p>I am trying to set PRAGMA foreign_key = ON; in sqlite database. I code some software in java using jdbc driver for sqlite, this one: <a href="http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC" rel="nofollow">http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC</a>.</p>
  
  <p>I am also using connection pooling to speed up queries for DB. I am using this library: 
  <a href="http://commons.apache.org/dbcp/" rel="nofollow">http://commons.apache.org/dbcp/</a>.</p>
  
  <p>Up to this point, all is good. Now, I need to set PRAGMA setting, concretely PRAGMA foreign_key = ON; before creating tables, because I need to be sure about consistency between some columns in db.</p>
  
  <p>When I create DB, it is automatically set to OFF. So I have to turn it on in order to use it. </p>
  
  <p>But I do not know how to do it, the way I am preparing poolable data source is like this:</p>
  
  <pre><code>    public static DataSource getDataSource(String connectURI) {
  GenericObjectPool connectionPool = new GenericObjectPool(null);
  ConnectionFactory connectionFactory =
      new DriverManagerConnectionFactory(connectURI, null);
  PoolableConnectionFactory poolableConnectionFactory =
      new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
  DataSource dataSource = new PoolingDataSource(connectionPool);
  return dataSource;
  }
  </code></pre>
  
  <p>But I do not know how to set that pragma properly, I found that this one is possible:</p>
  
  <pre><code>SQLiteConfig config = new SQLiteConfig();
  config.enforceForeignKeys(true);
  </code></pre>
  
  <p>But I do not know how to use it in connection with that poolable tricky settings ...</p>
  
  <p>Any ideas?</p>