SQLITE with JAVA in Windows 10, first attempt
(1) By Martin Packham (martinpackham) on 2022-02-14 15:34:48 [link] [source]
I am trying to run SQLITE in Java in Windows 10.
I receive the message "No suitable driver found for jdbc:sqlite:D:/sqlite/notification.db"
The command is: "java -classpath ".;.:sqlite-jdbc-3.36.0.3.jar" Connect"
My Connect.java program is from sqlite.tutorial.net.
My database "notification.db" works outside of Java using sqlite3.exe.
Can someone help me? If the sqlite jdbc driver is not the correct one can someone tell me which one I need and from where I can download it?
Thanks for any help.
(2) By Martin Packham (martinpackham) on 2022-02-16 09:27:27 in reply to 1 [link] [source]
Is there anyone who uses SQLITE in JAVA in Windows? Does it work at all?
(3) By ddevienne on 2022-02-16 09:39:37 in reply to 2 [link] [source]
Not much Java on this forum I'm afraid, no.
You might have more answers in a more Java-focused forum, or Stack Overflow
(4) By Larry Brasfield (larrybr) on 2022-02-16 09:46:23 in reply to 2 [source]
With the right JDBC adapter, SQLite can be used for CRUD operations on whatever platform the adapter is built for. I have used one with Squirrel on Windows. As I recall, it was difficult to find up-to-date adapters, and it was necessary to install a JDK to build one. I found that using a JDBC-to-ODBC adapter with an ODBC adapter for SQLite was workable and easier in some respects. (I do not remember the details, and they are off-topic here anyway.)
This is all off-topic or tangential to this forum's purposes. That is why your post got no response for a while.
(5.1) By ddevienne on 2022-02-16 10:10:50 edited from 5.0 in reply to 1 [link] [source]
I've never used JDBC or SQLite in Java, but I've done lots of Java + JNI years ago.
I suspect your sqlite-jdbc.jar
depends on the native SQLite compiled code, via JNI,
the Java Native Interface that specify how Java and native code with a C-like ABI interact.
This means that it must be able to locate an SQLite DLL, under some specific name.
Perhaps it packs the DLL into its Jar, and unpacks it at runtime to System.loadLibrary()
it?
In any case, Java code that cannot access the native code it depends on will fail to class-load.
And the JDBC infrastructure that attempts to load a driver might not report that error nicely.
Lots of conjectures and guesses above, but hopefully it will give you hints for where to look on your own.
(6.2) By ddevienne on 2022-02-16 10:33:57 edited from 6.1 in reply to 5.1 [link] [source]
From https://github.com/xerial/sqlite-jdbc:
Our SQLiteJDBC library requires no configuration since native libraries ... are assembled into a single JAR file
From the doc of that JDBC driver, it appears it packs its shared-libraries indeed...
Be careful using such Java code that transparently executes arbitrary native code behind the scene :)
Finally, I'm not following the Java world that much these days, but I've vaguely heard of recent changes in the JRE/JDK security-managers,
and those do interact with native code loading, so it's possible this is related, if you just downloaded the latest JRE/JDK.
PS: Here's the code that unpacks and loads the native shared library, if you are interested in the details, and want to debug it yourself.
(7) By MBL (UserMBL) on 2022-02-16 16:42:52 in reply to 5.1 [link] [source]
Somewhere in this forum I got the hint about the following site:
mvnrepository.com (follow the link)
I am using this JDBC driver with BaseX and KNIME Analytics Platform without any issues with the URL template as shown here:
jdbc:sqlite:[location=file?<file>][location=in-memory?file:<database>?mode=memory&cache=shared]
(8) By Donal Fellows (dkfellows) on 2022-02-16 17:18:46 in reply to 1 [link] [source]
You don't say which JDBC driver/connector you're using to bridge between your Java code and the SQLite base implementation. There are several. As SQLite itself obviously works on your platform (given what you say), you should ask on the driver/connector's forums and/or support channels.
For what it's worth, we use the Xerial driver and haven't had problems with it so far, but we're not really a Windows development place. Some of our users may be doing so, and they've not reported problems. (There are aspects of it that are very finicky to do with how JDBC manages transactions, but those aren't SQLite's fault.)