-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newer versions (>sqlite-jdbc-3.43) can't open example database "chinook.db" #1093
Comments
"No suitable driver found for" sounds more like a problem with the class path / module path / project setup. This is a default error message from within the DriverManager class. The DriverManager uses a simple ServiceLoader based mechanism to lookup all viable JDBC drivers and checks if one of the found drivers can handle the provided URL. If the error message get's thrown, no driver has been found on the class path, that can handle URLs of a certain pattern. In a very basic Maven project consisting of the parts below, I cannot reproduce the issue. Tested with the versions you have mentioned and the latest release 3.46.0.0. pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.46.0.0</version>
</dependency>
</dependencies>
</project> Test.java import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Test {
public static void main(String[] args) {
String url = "jdbc:sqlite:chinook.db";
try (Connection conn = DriverManager.getConnection(url)) {
System.out.println("Connection to SQLite has been established.");
try (PreparedStatement statement = conn.prepareStatement("SELECT COUNT(*) FROM ALBUMS");
ResultSet result = statement.executeQuery()) {
if (result.next()) {
System.out.println("Got %d albums.".formatted(result.getInt(1)));
}
}
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
}
|
I tried reproducing the issue while using your dependecy code (with different jdbc versions). Now it works everytime. This is quite interesting because initially in the former project I used I also just switched the dependency (without changing the source code!) and the problem occured. Nevermind, as it cannot be reproduced anymore I would propose to close this issue. |
Describe the bug
A very common sqlite example database exists: chinook.db. It can be downloaded here.
Earlier versions of sqlite-jdbc allowed connecting to this database, e.g., sqlite-jdbc-3.36.0.3.jar works. Newer versions such as sqlite-jdbc-3.43.2.2.jar or sqlite-jdbc-3.45.2.0.jar result in an SQLException "No suitable driver found for jdbc:sqlite:chinook.db"
To Reproduce
Create IntelliJ Project, put chinook.db inside the project folder. Download sqlite-jdbc-3.45.2.0.jar, add it to the project's classpath. Build and execute the following code:
` public static void main(String[] args) {
Connection conn = null;
try {
String url = "jdbc:sqlite:chinook.db";
conn = DriverManager.getConnection(url); // This line fails
Expected behavior
Database connection should be opened, instead "No suitable driver found for jdbc:sqlite:chinook.db". When switching inside this project to an older lib version, connection is successful.
Environment (please complete the following information):
Additional context
May be a chinook.db problem?
The text was updated successfully, but these errors were encountered: