[英]Popular error - org.sqlite.JDBC
package aplikacjajava;
import java.sql.*;
public class main
{
public main( String args[] )
{
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:projekt.db");
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Opened database successfully");
}
}
Error:错误:
java.lang.ClassNotFoundException: org.sqlite.JDBC
I know that I'm missing JDBC driver.我知道我缺少 JDBC 驱动程序。 How to install it on Fedora?
如何在 Fedora 上安装它?
I don't how to add some "path" and what is this at all.我不知道如何添加一些“路径”以及这是什么。 I need something like step-by-step explanation... This is first time when I met with such a problem.
我需要一步一步的解释......这是我第一次遇到这样的问题。
You usually use Maven, Gradle or manual dependency management when using Java.在使用 Java 时,您通常使用 Maven、Gradle 或手动依赖管理。 Linux package managers are very limited in java support.
Linux 包管理器在 Java 支持方面非常有限。
After I set the classpath from the command prompt, I could use the Database by running java javafile.java
, and the database was working fine only from the command prompt.从命令提示符设置类路径后,我可以通过运行
java javafile.java
来使用数据库,并且数据库只能在命令提示符下正常工作。
The Eclipse IDE does not recognize the class. Eclipse IDE 无法识别该类。 While I tried to add
external jar file
, the good news was when I defined the classpath as a variable inside the Eclipse IDE, then the issue was solved completely.当我尝试添加
external jar file
,好消息是当我将类路径定义为 Eclipse IDE 中的变量时,问题就完全解决了。
I did notice your request and tried to add well-detailed instructions on how to fix that issue.我确实注意到了您的请求,并尝试添加有关如何解决该问题的详细说明。
For also solving this issue, follow the steps below:要解决此问题,请按照以下步骤操作:
sqlite-jdbc-XXX.jar
filesqlite-jdbc-XXX.jar
文件properties
properties
Java build path
and click Add variable
Java build path
并单击Add variable
Configure variables
and then click New
Configure variables
,然后单击New
Class.forName("org.sqlite.JDBC");
Class.forName("org.sqlite.JDBC");
上命名变量名称字段一样命名它Class.forName("org.sqlite.JDBC");
line, that means your variable name is: org.sqlite.JDBC
org.sqlite.JDBC
sqlite-jdbc-XXX.jar
filesqlite-jdbc-XXX.jar
文件Finally, I got results from the database also in the Eclipse IDE.最后,我也从 Eclipse IDE 中的数据库中获得了结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.