- Notifications
You must be signed in to change notification settings - Fork658
SQLite JDBC Driver
License
Apache-2.0, BSD-2-Clause licenses found
Licenses found
xerial/sqlite-jdbc
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
SQLite JDBC is a library for accessing and creatingSQLite database files in Java.
Our SQLiteJDBC library requires no configuration since native libraries for major OSs, including Windows, macOS, Linux etc., are assembled into a single JAR (Java Archive) file.
The project is maintained, but is not being actively developed:
We follow every new version of SQLite and will release a corresponding version of our driver.
Bugs will be investigated, and fixed if possible.
New features are driven by pull requests.
The current maintainer of the project isgotson.
➡️ More usage examples and configuration are available inUSAGE.md
SQLite JDBC is a library for accessing SQLite databases through the JDBC API. For the general usage of JDBC, seeJDBC Tutorial orOracle JDBC Documentation.
Download
sqlite-jdbc-3.51.2.0.jarthen append this jar file into your classpath.Open a SQLite database connection from your code. (see the example below)
Assumingsqlite-jdbc-3.51.2.0.jar is placed in the current directory.
> javac Sample.java> java -classpath".;sqlite-jdbc-3.51.2.0.jar" Sample# in Windowsor> java -classpath".:sqlite-jdbc-3.51.2.0.jar" Sample# in macOS or Linuxname = leoid = 1name = yuiid = 2
importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassSample {publicstaticvoidmain(String[]args) {// NOTE: Connection and Statement are AutoCloseable.// Don't forget to close them both in order to avoid leaks.try (// create a database connectionConnectionconnection =DriverManager.getConnection("jdbc:sqlite:sample.db");Statementstatement =connection.createStatement(); ) {statement.setQueryTimeout(30);// set timeout to 30 sec.statement.executeUpdate("drop table if exists person");statement.executeUpdate("create table person (id integer, name string)");statement.executeUpdate("insert into person values(1, 'leo')");statement.executeUpdate("insert into person values(2, 'yui')");ResultSetrs =statement.executeQuery("select * from person");while(rs.next()) {// read the result setSystem.out.println("name = " +rs.getString("name"));System.out.println("id = " +rs.getInt("id")); } }catch(SQLExceptione) {// if the error message is "out of memory",// it probably means no database file is founde.printStackTrace(System.err); } } }
Our SQLite JDBC driver package (i.e.,sqlite-jdbc-3.51.2.0.jar) contains threetypes of native SQLite libraries (sqlitejdbc.dll,sqlitejdbc.dylib,sqlitejdbc.so),each of them is compiled for Windows, macOS and Linux. An appropriate native libraryfile is automatically extracted into your OS’s temporary folder, when your programloadsorg.sqlite.JDBC driver.
Since sqlite-jdbc-3.6.19, the natively compiled SQLite engines will be used forthe following operating systems:
| x86 | x86_64 | armv5 | armv6 | armv7 | arm64 | ppc64 | riscv64 | |
|---|---|---|---|---|---|---|---|---|
Windows | ✔ | ✔ | ✔ | ✔ | ||||
macOS | ✔ | ✔ | ||||||
Linux (libc) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (musl) | ✔ | ✔ | ✔ | |||||
Android (API Level 24+) | ✔ | ✔ | ✔ | ✔ | ||||
FreeBSD | ✔ | ✔ | ✔ |
In the other OSs not listed above, the pure-java SQLite is used. (Applies to versions before 3.7.15)
If you want to use the native library for your OS,build the source from scratch.
Sqlite JDBC supportsGraalVM native-image out of the box starting from version 3.40.1.0.There has been rudimentary support for some versions before that, but this was not actively tested by the CI.
By default, thesqlitejdbc library for the compilation target will be included in the native image, accompanied by the required JNI configuration.At runtime, this library will be extracted to the temp folder and loaded from there.For faster startup however, it is recommended to set theorg.sqlite.lib.exportPath property at build-time.This will export thesqlitejdbc library at build-time to the specified directory, and the library will not be included as a resource.As a result, the native image itself will be slightly smaller and the overhead of exporting the library at run-time is eliminated,but you need to make sure the library can be found at run-time.The best way to do this is to simply place the library next to the executable.
This example uses thenative-build-tools maven plugin:
<plugin> <groupId>org.graalvm.buildtools</groupId> <artifactId>native-maven-plugin</artifactId> <configuration> <buildArgs> <buildArg>-Dorg.sqlite.lib.exportPath=${project.build.directory}</buildArg> </buildArgs> </configuration></plugin>
This will automatically place thesqlitejdbc library in the/target folder of your project, creating a functional execution environment.When packaging the resulting app, simply include the library in the distribution bundle.
Download fromMaven Central or from thereleases page.
<dependencies> <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.51.2.0</version> </dependency></dependencies>
Snapshots of the development version are available inSonatype’s snapshots repository.
Maven Central resources are signed usingGPG and the signature files, ending in .asc, are available in the same location as the other downloads.
The following key is currently used to sign releases:
-----BEGIN PGP PUBLIC KEY BLOCK-----Comment: C1CB A75E C9BD 0BAF 8061 9354 59E0 5CE6 1818 7ED4Comment: Taro L. Saito (For GitHub Actions) <leo@xerial.org>xjMEYuRVGhYJKwYBBAHaRw8BAQdA2Dp4m1Yhtb1g94pQzzL24FuP6b9KXF8lP9DhhZnynhfNM1Rhcm8gTC4gU2FpdG8gKEZvciBHaXRIdWIgQWN0aW9ucykgPGxlb0B4ZXJpYWwub3JnPsKUBBMWCgA8FiEEwcunXsm9C6+AYZNUWeBc5hgYftQFAmLkVRoCGwMFCwkIBwIDIgIBBhUKCQgLAgQWAgMBAh4HAheAAAoJEFngXOYYGH7UfPwBAK7xTVRebZeWcAwmGaMUsbg7SgJou8xnkhByObPLUC/4AQDPsZeYmi4KXyXPzmqhCicdY+ZSJWIDQqitK2ujPDFXA844BGLkVRoSCisGAQQBl1UBBQEBB0Atu9kejBi+6wfOT0a9z/LYEEdNXM/VX6xt1onKToPPdQMBCAfCeAQYFgoAIBYhBMHLp17JvQuvgGGTVFngXOYYGH7UBQJi5FUaAhsMAAoJEFngXOYYGH7UlMABAKyRCazhVyUFg5FOpAnmckBY38CaMGPPLXVyY8Kr6dYFAP9wYLu7nsDZCOXkAgS+et4Pk1WZCggoYUkxsX1o0KZXBQ===Wyas-----END PGP PUBLIC KEY BLOCK-----
The project’s version follows the version of the SQLite library that is bundled in the jar, with an extra digit to denote the project’s increment.
For example, if the SQLite version is3.39.2, the project version will be3.39.2.x, wherex starts at 0, and increments with every release that is not changing the SQLite version.
If the SQLite version is updated to3.40.0, the project version will be updated to3.40.0.0.
You may need to add shade plugin transformer to solveNo suitable driver found for jdbc:sqlite: issue.
<transformerimplementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/services/java.sql.Driver</resource></transformer>
<dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.51.2.0</version></dependency>
We are always looking for:
Please read ourcontribution guide.
About
SQLite JDBC Driver
Topics
Resources
License
Apache-2.0, BSD-2-Clause licenses found
Licenses found
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.