score:50
Your classpath is missing the jar(s) that contain the sqlite classes and driver. You need something like sqlite-jdbc-3.7.2.jar or your applicable version.
If you are sure the jar is there, try adding this line of code before you create a connection:
Class.forName("org.sqlite.JDBC");
score:0
I was facing similar issues using a simple gradle configuration as follows
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.23.1'
}
jar {
manifest {
attributes 'Main-Class': 'rewards.simulator.MainSimulator'
}
}
I later found that gradle build was creating a jar which was not including any external dependencies. Following configuration is to be used to include all your dependent libraries in the resulting jar file, along with your source files, to create a fat-jar:
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.23.1'
}
jar {
manifest {
attributes 'Main-Class': 'rewards.simulator.MainSimulator'
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
score:0
problem of version 3.7.2 try to install 3.21.0 it
score:1
Below is the link of central repository from where you can download latest driver files.
https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.32.3.2/
Make sure that you download sqlite-jdbc-version.jar file and not other files. Hope this might help
score:2
If you use Maven and want to build an executable jar, you could decide to import the content of the sqlite jar into your own produced jar:
<plugins>
<!-- any other plugins -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addClasspath>true</addClasspath>
<mainClass>MyPackage.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
You will not have to add specific classpath or implicit usage as proposed in the others answers.
score:4
There is something more than just Class.forName.
In the case you did both things below: - Added the sqlite jar library to lib folder under your project, reference to it in the project build path. - Added Class.forName("org.sqlite.JDBC") statement. And the error message "No suit driver" still appear, its may caused by your database path. If you are using Windows: Instead of:
DriverManager.getConnection("D:\\db\\my-db.sqlite").
You should use:
DriverManager.getConnection("jdbc:sqlite:D:\\db\\my-db.sqlite").
The "jdbc:sqlite:" will do the trick.
If you are using Linux, just change the seperator character: DriverManager.getConnection("jdbc:sqlite:/your/somepath/my-db.sqlite").
score:14
I got the same problem. I used maven and added dependency:
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.15.1
</version>
</dependency>
It could be compiled and I got:
No suitable driver found for jdbc:sqlite:xx.db
I Checked the classpath and I was sure sqlite-jdbc-3.15.1.jar was there. I guess that for some reason, the Class was not loaded, I don't know why. so I added
Class.forName("org.sqlite.JDBC");
at the beginning of my code. It worked!
And ,I delete the line above. It still works! I cleaned the project and rebuild it, no more Class.forName() is needed!!! I still Don't know why. But the problem is solved. I think Class.forName() can be used for diagnose if the class you need is in the classpath.
Source: stackoverflow.com
Related Query
- Unable to connect to mysql database using jsp page but below error java.sql.SQLException: No suitable driver found jdbc:mysql://localhost:3306/dbname
- Unable to connect to database (No suitable driver found)
- Unable to connect to SQL Server via JDBC. No suitable driver found for jdbc:sqlserver://
- Creating a Oracle database connection from Eclipse but facing an issue as No suitable driver found for jdbc:oracle:thin:@//hostname:1521/SERVICE_NAME
- Eclipse + Equinox : Can not connect to database, SQLException No suitable driver found
- Cause of No suitable driver found for
- No suitable driver found for jdbc mysql?
- No suitable driver found for jdbc:h2:tcp
- Unable to connect to GitHub within Eclipse due to SunCertPathBuilderException: certificate not found
- Unable to connect to a postgresql database with spring roo, eclipse, gwt, and hibernate
- No suitable MySQL driver found for JBoss application
- No suitable Driver found in production and not in eclipse
- Unable to connect with mysql database using android eclipse?
- Java JDBC - No suitable Driver found
- No suitable driver found for jdbc:derby:myDBtest
- What else am I missing? I get an error : No suitable driver found for jdbc
- "no suitable driver found for jdbc" when using DataSource (Java Eclipse)
- No suitable driver found for jdbc:mysql, on server with Maven (Java)
- No suitable driver found (but the driver is there!)
- unable to connect to remote database located on server
- Getting this Error : -" java.sql.SQLException: No suitable driver found for". When I use Hibernate Config for reverse eng. my DB
- No suitable driver found for jdbc:mysql//localhost:3306/Test in Eclipse
- Eclipse - Hibernate : No suitable driver found for jdbc:mysql://localhost:3306/hibernatedb
- java.sql.jdbc.SQLException: No suitable driver on when connect to XAMPP MYSQL
- Postgres JDBC Issue - No suitable driver found for postgresql://localhost:5432/postgres - JDBC driver already configured on buildpath
- No suitable driver found for jdbc mysql driver
- java.sql.SQLException: No suitable driver found for jdbc:mariadb://localhost:3306/mydatabase
- unable to connect to mysql database through jsp , Class.forName(com.mysql.jdbc.Driver); not loading
- java.sql.SQLException: No suitable driver found for url+dbName,UserId=?&password=?
- how to solve java.sql.SQLException: No suitable driver found for jdbc:derby:
More Query from same tag
- Import spring project into another spring project
- How to compile a GUI in Java using Eclipse with the given code
- Eclipse not compiling because of ClassNotFoundException
- How do I use existing sourcecode for integration in Eclipse?
- Text View does not get update through handler
- dev mode in Eclipse OSGI run configuration
- How to update sdk in android
- How can I get the results of a search in eclipse
- Install [java library] in Eclipse
- creating my first liferay portlet(maven) and I get an error when I deploy
- AbstractUIPlugin error and Missing tabs in plugin.xml from eclipse
- Visual Studio style Output Console Window in Eclipse
- How to execute Test suit in TestNg and eclipse
- IDE with better Maven support than Eclipse with m2e?
- Failed to find class JsonObject
- Make eclipse Syntax Coloring exact as visual studio Syntax Coloring
- MySQLConnection - Error on authenticateUser of "Multiple markers at this line"
- Eclipse reports rendering library more recent than ADT plug-in update Provisioning Error
- runtime error on emulator but not on phone nullpointer exception
- Eclipse Source / Organize Imports option does not show up for project or folder
- App crash, How to resolve?
- Field nameSpan has no corresponding field in template file Login.ui.xml
- Running a java application with spring-boot, and gradle on digitalocean
- JHipster - How to debug in Eclipse only one gateway (or microservice) in a microservices architecture?
- Is there a way to copy code from the Eclipse IDE without the rich-text formatting?
- eclipse tfs plugin won't connect to tfs server
- run-Jetty-run Eclipse plugin: allow only loopback connections
- Eclipse C printf() fail
- eclipse milo session not getting created when opc UA server restarts
- Eclipse RCP: Get rid of "reset perspective" message