From c23bd021ab7d61f8f0f471eac272e2101448e7fc Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Wed, 18 Sep 2024 18:19:25 -0500 Subject: [PATCH 1/2] Make slf4j optional, fall back on j.u.logging In order to avoid the hard dependency on slf4j, this patch abstracts the Logger interface and LoggerFactory factory to fall back on a java.util.logging-based implementation if slf4j is not present. Fixes #1094 --- README.adoc | 7 +- pom.xml | 1 + src/main/java/org/sqlite/JDBC.java | 8 +- .../java/org/sqlite/SQLiteJDBCLoader.java | 4 +- src/main/java/org/sqlite/core/NativeDB.java | 4 +- .../sqlite/jdbc3/JDBC3DatabaseMetaData.java | 4 +- .../java/org/sqlite/jdbc3/JDBC3Statement.java | 4 +- src/main/java/org/sqlite/util/Logger.java | 18 +++ .../java/org/sqlite/util/LoggerFactory.java | 130 ++++++++++++++++++ src/main/java/org/sqlite/util/OSInfo.java | 2 - .../sqlite/architecture/CodingRulesTest.java | 2 - 11 files changed, 164 insertions(+), 20 deletions(-) create mode 100644 src/main/java/org/sqlite/util/Logger.java create mode 100644 src/main/java/org/sqlite/util/LoggerFactory.java diff --git a/README.adoc b/README.adoc index 05da93e19..4a3a047ce 100644 --- a/README.adoc +++ b/README.adoc @@ -29,19 +29,18 @@ SQLite JDBC is a library for accessing SQLite databases through the JDBC API. Fo . <> `sqlite-jdbc-{project-version}.jar` then append this jar file into your classpath. -. https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar[Download] `slf4j-api-1.7.36.jar` then append this jar file into your classpath. . Open a SQLite database connection from your code. (see the example below) === Example usage -Assuming `sqlite-jdbc-{project-version}.jar` and `slf4j-api-1.7.36.jar` are placed in the current directory. +Assuming `sqlite-jdbc-{project-version}.jar` is placed in the current directory. [source,shell,subs="attributes+"] ---- > javac Sample.java -> java -classpath ".;sqlite-jdbc-{project-version}.jar;slf4j-api-1.7.36.jar" Sample # in Windows +> java -classpath ".;sqlite-jdbc-{project-version}.jar" Sample # in Windows or -> java -classpath ".:sqlite-jdbc-{project-version}.jar:slf4j-api-1.7.36.jar" Sample # in macOS or Linux +> java -classpath ".:sqlite-jdbc-{project-version}.jar" Sample # in macOS or Linux name = leo id = 1 name = yui diff --git a/pom.xml b/pom.xml index 7f3d2782e..bee67a8c5 100644 --- a/pom.xml +++ b/pom.xml @@ -415,6 +415,7 @@ org.slf4j slf4j-api 1.7.36 + true