英文:
"No suitable driver found for jdbc:sqlite" problem. What am I doing wrong?
问题
我更换了电脑,因此重新启动了使用驱动程序连接JDBC和数据库的整个过程。为了缩短故事,我将发布截屏。希望有人能帮助,因为我不知道问题出在哪里。
步骤2:我进入InteliJ,在"File/ProjectStructure/Libraries"中添加了完全相同的.jar文件。
步骤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:
Step 2: I went to InteliJ in File/ProjectStructure/Libraries and added exact same .jar file.
Step 3: After that I went to make a Connection with my db. It is located here:
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:
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.32.3.2</version>
</dependency>
and for gradle:
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.32.3.2'
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论