Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SQLite JDBC Driver

License

Apache-2.0, BSD-2-Clause licenses found

Licenses found

Apache-2.0
LICENSE
BSD-2-Clause
LICENSE.zentus
NotificationsYou must be signed in to change notification settings

xerial/sqlite-jdbc

GitHub Workflow Status (branch)Join the chatMaven Centraljavadocv?color=blue&label=maven%20snapshot&metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven snapshots%2Forg%2Fxerial%2Fsqlite jdbc%2Fmaven metadata

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.

Project Status

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.

Usage

➡️ 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.

  1. Downloadsqlite-jdbc-3.51.2.0.jarthen append this jar file into your classpath.

  2. Open a SQLite database connection from your code. (see the example below)

Example usage

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

Sample.java

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);        }      }    }

How does SQLiteJDBC work?

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.

Supported Operating Systems

Since sqlite-jdbc-3.6.19, the natively compiled SQLite engines will be used forthe following operating systems:

x86x86_64armv5armv6armv7arm64ppc64riscv64

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.

GraalVM native-image support

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.

CLI example

native-image -Dorg.sqlite.lib.exportPath=~/outDir -H:Path=~/outDir -cp foo.jar org.example.Main

This will place both thesqlitejdbc shared library and the native-image output in the~/outDir folder.

Maven example

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

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.

Validating downloads

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-----

Project versioning explained

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.

Hint for maven-shade-plugin

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>

How can I help?

We are always looking for:

  • Reviewers for issues or PRs, you can checkGitHub labels

  • Contributors to submit PRs, you can checkGitHub labels andGitHub labels

Please read ourcontribution guide.

About

SQLite JDBC Driver

Topics

Resources

License

Apache-2.0, BSD-2-Clause licenses found

Licenses found

Apache-2.0
LICENSE
BSD-2-Clause
LICENSE.zentus

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

[8]ページ先頭

©2009-2026 Movatter.jp