I am learning to enable my Java application to communicate with a MS Access database.
I am unsure of one method, the Class.forName() method. The parameter I pass is “sun.jdbc.odbc.JdbcOdbcDriver”, which loads the jdbc:odbc bridge for accessing a database.
What does the Class.forName() do exactly and why is it needed?
Thank you very much.
Class.forName()causes ClassLoader to load the class into memory. JDBC driver classes have static initializers that register them with DriverManager for further use. After you useClass.forName(), and useDriverManager.getConnection("jdbc:*", database, username, password), thejdbc:is already loaded in memory.