Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On a linux desktop, when I tried,</p> <pre><code>connection = DriverManager.getConnection("jdbc:sqlite:/path/to/test.db;foreign keys=true;"); </code></pre> <p>sqlite3 (3.7.13) thought that my database <strong>file</strong> was <strong>/path/to/test.db;foreign keys=true</strong>. This led to the strange, but I guess appropriate, error: <strong>table does not exist</strong></p> <p>See <a href="https://stackoverflow.com/questions/9895030/how-to-solve-no-such-table-while-inserting-exception-in-sqlite-data-base">how to solve no such table while inserting exception in sqlite data base</a></p> <p>I thought I had fixed both of these issues by stuffing the foreign key statement into a property like so:</p> <pre><code>private final Properties connectionProperties = new Properties(); connectionProperties.setProperty("PRAGMA foreign_keys", "ON"); private final String connectionString = String.format("jdbc:sqlite:%s", absolute_path_to_sqlite_db); Connection connection = DriverManager.getConnection(connectionString, connectionProperties); </code></pre> <p>But even tho the database name issue was resolved, SQLite was still allowing constraint violations. Some more noodling with Xerial's driver and this is what finally worked:</p> <pre><code>private final Properties connectionProperties = new Properties(); SQLiteConfig config = new SQLiteConfig(); config.enforceForeignKeys(true); connectionProperties = config.toProperties(); private final String connectionString = String.format("jdbc:sqlite:%s", absolute_path_to_sqlite_db); Connection connection = DriverManager.getConnection(connectionString, connectionProperties); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload