Skip to content

Commit

Permalink
feat: add SQLiteDataSource #setBusyTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mruddy authored Mar 8, 2023
1 parent 8be7243 commit 12f2113
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/sqlite/SQLiteDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ public void setReadOnly(boolean readOnly) {
config.setReadOnly(readOnly);
}

/**
* Sets the amount of time that the connection's busy handler will wait when a table is locked.
*
* @param milliseconds The number of milliseconds to wait.
* @see <a
* href="https://www.sqlite.org/pragma.html#pragma_busy_timeout">https://www.sqlite.org/pragma.html#pragma_busy_timeout</a>
*/
public void setBusyTimeout(int milliseconds) {
config.setBusyTimeout(milliseconds);
}

/**
* Sets the suggested maximum number of database disk pages that SQLite will hold in memory at
* once per open database file.
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/sqlite/SQLiteDataSourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,16 @@ public void encoding() throws Exception {
}
}
}

@Test
public void setBusyTimeout() {
final SQLiteDataSource ds = new SQLiteDataSource();
ds.setBusyTimeout(1234);
assertThat(
ds.getConfig()
.toProperties()
.getProperty(SQLiteConfig.Pragma.BUSY_TIMEOUT.pragmaName))
.isEqualTo("1234");
assertThat(ds.getConfig().getBusyTimeout()).isEqualTo(1234);
}
}

0 comments on commit 12f2113

Please sign in to comment.