java.sql.SQLException:找不到适合jdbc:sqlite的驱动程序 [英] java.sql.SQLException: No suitable driver found for jdbc:sqlite
问题描述
我的Java程序(我的第一个)似乎是挂起
在以下标准代码行中:
My Java program (one of my very first) seems to be hanging
at the following line of standard code:
Class.forName("org.sqlite.JDBC");
Connection c = null;
Statement stmt = null;
c = DriverManager.getConnection("jdbc:sqlite:test.db");
c.setAutoCommit(false);
我收到以下错误
:
java.sql.SQLException: No suitable driver found for jdbc:sqlite:test.db
然而,在运行java应用程序时,我提供 jdbc驱动程序的正确位置
(我认为);
However, when running the java application I'm providing the correct location of the jdbc driver
(I think);
sudo java -cp ./jsoup-1.7.3.jar:./sqlite-jdbc-3.7.2.jar:. <AppName>
任何想法如何继续?
感谢百万
any idea how to proceed?
thanks a million
推荐答案
sudo java -cp ./jsoup-1.7.3.jar:./sqlite-jdbc-3.7.2.jar:.
任何想法如何进行?谢谢一百万
any idea how to proceed? thanks a million
是的。我看到的两个主要问题。一,除非你有充分的理由,否则不要用 sudo
运行你的程序。如果你这样做,它可能会导致你的主要痛苦。
Yes. Two major problems I see. One, unless you have a very good reason, don't run your program with sudo
. It could cause you major pain later if you do.
其次,你的类路径看起来不正确。 jar文件位于它上面。第一部分应该是搜索的路径,第二部分应该是要搜索的jar。
Second, your classpath doesn't look correct. jar files are located on it. The first part should be the path to search and the second the jars to search for.
java -cp ".:jsoup-1.7.3.jar:sqlite-jdbc-3.7.2.jar" ...
最后,我假设您从 sqlite here 和 jsoup here 并在当前目录中包含 jar
文件,如果它仍无法正常工作,您应该检查这些文件文件是正确的。
Finally, I assume you downloaded from sqlite here and jsoup here and have the jar
files in your current directory and if it still isn't working you should check those files are correct.
$ sha1sum sqlite-jdbc-3.7.2.jar
cea9f7f8e6bcb580d953a8651fb8391640de0f85 sqlite-jdbc-3.7.2.jar
$ sha1sum jsoup-1.7.3.jar
ab1f22cadc2f8b514e55ba368f5128056fe304da jsoup-1.7.3.jar
这篇关于java.sql.SQLException:找不到适合jdbc:sqlite的驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!