Allow user to specify busy-timeout when opening a database connection.

Issue #27 resolved
Rupinder Gill
created an issue

There currently seems to be no way to set sqlite's busy-timeout. It seems from the code that the timeout is currently set to 3000ms... which may be sufficient for most cases, but with a large number of concurrent writes happening on a large db (all from multiple threads in single process), this value is occasionally turning out to be too small.

Comments (7)

  1. Grace Batumbya

    <strike>The issue here is the hard coded 30 sec in

    ..., fileName, openModeFlags);

    My planned fix is to add a property, openTimeOut, to SQLiteConfig. This way one can specify a timeout for opening a connection.

    This of course now depends on resolving issue #32 </strike>

  2. Grace Batumbya

    Strike my previous comment.

    1. The default 3 second busy_timeout remains.
    2. Added SQLiteConfig.setBusyTimeout and "busy_timeout" to configuration properties for the connection.
    Properties props = new Properties ();
    props. put ("busy_timeout", "33000");
    Conection con = DriverManager.getConnection("jdbc:sqlite:", props);
    SQLiteConfig config = new SQLiteConfig();
    config.setBusyTimeout = 66000;
    Connection con = new SQLiteDataSource(config).getConnection(); // datasource creates connections with 66000 ms busy_timeout

    3 . The methods setBusyTimeout and getBusyTimeout have been added to SQLiteConnection.

    package org.test;
    import org.sqlite.SQLiteConnection;
    public class TestBusyTimeout {
       Connection con = DriverManager.getConnection("jdbc:sqlite:");
  3. Log in to comment