In this tutorial, we will show you how to download SQLite JDBC Driver and connect to the SQLite database via JDBC, source code and screenshot are included. The JAR file includes both Java class files and SQLite binaries for Mac OX S, Linux, and Windows, Both 32-bit and 64-bit.
Active6 years, 9 months ago
I'm migrating an Eclipse project from Windows to Mac. For some reason, I'm getting a classpath problem specifically on loading the SQLite JDBC driver in MAC. Windows copy is OK.
Here's what I did:
Jdbc Driver Download
- Displayed System.getProperty('java.class.path') - the result is exactly the same between the PC and MAC. Same JARs and versions being imported, nothing extra nor missing.
- Initially I was referencing sqlite from the Maven local repository. I took out the actual sqlite-jdbc-3.7.2.jar, moved it into some place and did a direct reference to it in the build path. But the problem remains.
A few observations:
In Windows, typing 'org.sqlite.' in the code gives me a bunch of auto-complete options, while in Mac, it does not give anything.
Other JARs seem to be imported just fine (ex. I have a JodaTime jar and it's working just fine)
Is this a classpath problem, or do I need a Mac distribution of SQLite-JDBC? I don't see any specific jar on on their site. My current copy was downloaded through Maven dependencies.
Thanks in advance.
Jops
JopsJops19.5k11 gold badges42 silver badges57 bronze badges
1 Answer
The problem is fixed.
I simply replaced my current JAR with a fresh copy from xerial.org, and it worked.
Either the initial JAR I got from the Maven dependency download was corrupted, or some file permissions were preventing the JVM from accessing the JAR's contents.
JopsJops19.5k11 gold badges42 silver badges57 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged javasqliteclasspath or ask your own question.
RazorSQL ships with a JDBC driver that can be used to connect to SQLite. This is the recommended way to connect to SQLite. When connecting to SQLite via JDBC, RazorSQL needs to know whether to connect to an existing SQLite database file or whether the connection is for a new SQLite database. If using an existing SQLite database, the location of the SQLite database file needs set in the Database File field. If connecting to a new SQLite database, the location / name of the new database file that should be created needs entered in the Database File field.
RazorSQL provides a custom SQLite driver that can communicate with SQLite via the SQLite command line program. This connection method is no longer recommended, but is included for legacy support. RazorSQL for Windows ships with the SQLite command line program, and SQLite is included on macOS / Mac OS X in the /usr/bin directory. For Linux systems, to use the RazorSQL SQLite driver, the SQLite command line program must first be installed. See www.sqlite.org to obtain SQLite for Linux.
Connecting to SQLite with the RazorSQL SQLite Driver
To connect to SQLite using the RazorSQL SQLite driver, open the connection wizard and select SQLite as the database type and RazorSQL SQLite Driver as the connection type. For Windows and Mac machines, the path to the SQLite command line program should be automatically populated. For Linux machines, use the browse button to navigate to the SQLite command line program.
Sqlite Jdbc Connection String
Next, choose whether to connect to an existing database file, or to have RazorSQL create a new SQLite database file. Enter the name of the existing or new file in the Database File field.
Connecting to SQLite via JDBC
Jdbc Driver Download
RazorSQL can also connect to SQLite via JDBC. To do this, an SQLite JDBC driver needs to be downloaded. To connect, in the connection wizard, select SQLite as the database type and JDBC as the connection type. See the documentation for the JDBC driver for the Driver Class and JDBC URL.