“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

huangapple go评论86阅读模式
英文:

"No suitable driver found for jdbc:sqlite" problem. What am I doing wrong?

问题

我更换了电脑,因此重新启动了使用驱动程序连接JDBC和数据库的整个过程。为了缩短故事,我将发布截屏。希望有人能帮助,因为我不知道问题出在哪里。

步骤1:我下载了驱动程序并将其存储在这里:
“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

步骤2:我进入InteliJ,在"File/ProjectStructure/Libraries"中添加了完全相同的.jar文件。
“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

步骤3:之后,我去连接我的数据库。它位于这里:
“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

步骤4:最后,我编写了以下语句:

try {
    Connection connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\Stefan\\people.db");
} catch (SQLException throwables) {
    throwables.printStackTrace();
}

我收到的是没有找到合适的驱动程序的消息。我仔细检查了一切,仍然不知道问题出在哪里。

英文:

I changed my computer so I restarted entire process of connecting JDBC with DB using Driver. To shorten the story, I will post screenshots. Hope someone can help, as I have no idea what the problem is..

Step 1: I downloaded driver and stored it here:
“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

Step 2: I went to InteliJ in File/ProjectStructure/Libraries and added exact same .jar file.
“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

Step 3: After that I went to make a Connection with my db. It is located here:
“No suitable driver found for jdbc:sqlite”问题。我做错了什么?

Step 4: Lastly I coded following statement:

try {
    Connection connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\Stefan\\people.db");
} catch (SQLException throwables) {
    throwables.printStackTrace();
}

What I get is no suitable driver found message. I double checked everything and still have no clue what the problem is.

答案1

得分: 1

如果您正在使用Maven / Gradle,请添加依赖项。

Maven示例:

<dependency>
    <groupId>org.xerial</groupId>
    <artifactId>sqlite-jdbc</artifactId>
    <version>3.32.3.2</version>
</dependency>

Gradle示例:

compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.32.3.2'
英文:

Add the dependency if you're using maven / gradle.

Example for maven:

&lt;dependency&gt;
    &lt;groupId&gt;org.xerial&lt;/groupId&gt;
    &lt;artifactId&gt;sqlite-jdbc&lt;/artifactId&gt;
    &lt;version&gt;3.32.3.2&lt;/version&gt;
&lt;/dependency&gt;

and for gradle:

compile group: &#39;org.xerial&#39;, name: &#39;sqlite-jdbc&#39;, version: &#39;3.32.3.2&#39;

答案2

得分: 1

你需要在类路径中包含sqlite3 jdbc驱动程序,并且如果你的类文件命名为Main.class,则使用java -cp C:/Programming/Database/sqlite-jdbc-3.32.3.2.jar:. Main来运行应用程序。如果不是,请使用相应的名称进行替换。

英文:

You need the sqlite3 jdbc driver in your classpath -- and run the application using java -cp C:/Programming/Database/sqlite-jdbc-3.32.3.2.jar:. Main if your classfile is named Main.class. If not substitute whatever it is named.

huangapple
  • 本文由 发表于 2020年10月7日 09:41:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/64236022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定