I am trying to execute a SQLite statement in Java.
import java.sql.*;
public class SQLiteJDBC
{
public static void main(String args[])
{
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:courses.db");
c.setAutoCommit(false);
System.out.println("Opened database successfully");
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Table and records created successfully");
}
}
I saved it with the name SQLiteJDBC.java which is legit and saved the sqlite-jdbc.jar in the same file as the java file. I am trying to execute as below:
javac SQLiteJDBC.java
java -classpath ".:sqlite-jdbc-3.8.11.2" SQLiteJDBC
And the execution ending up with the error: "Could not find or load main SQLiteJDBC" I tried many a times and getting the same error. Can anyone help me out please..
Aucun commentaire:
Enregistrer un commentaire