4
I am 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 have observed 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 I haven’t found the answer to, why use the DriverManager
as in the example above.
So why use the DriverManager
in that way specifically?
EDIT
Link to the question: Difference between using Sqliteconnection and Java Drivermanager
Your question is : "Why use the
DriverManager
"? This is your doubt?!– viana
Yes. I’ll ask the question.
– Robss70