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. How to install it on 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. Linux package managers are very limited in java support.
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.
The Eclipse IDE does not recognize the class. 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.
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
fileproperties
Java build path
and click Add variable
Configure variables
and then click New
Class.forName("org.sqlite.JDBC");
line, that means your variable name is: org.sqlite.JDBC
sqlite-jdbc-XXX.jar
fileFinally, I got results from the database also in the Eclipse IDE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.