I'm connecting to the SQLite database with the following code:
public SQLiteConnection conn() throws SQLException{
String path = System.getProperty("user.dir");
try {
return new SQLiteConnection(path, "DadosPastas.s3db");
} catch (Exception e) {
return null;
}
}
But I noticed several examples as follows:
import java.sql.*;
public class SQLiteJDBC {
public static void main( String args[] ) {
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Opened database successfully");
}
}
I've already researched and did not find the answer to, why use DriverManager
as in the example above.
So why use DriverManager
in this way specifically?
EDIT
Link for the question: Difference between using SQLiteConnection and Java DriverManager