Class.forName():
- The most common approach to register a driver is to use Java’s Class.forName() method.
- Class.forName() method is to dynamically load the driver’s class file into memory, which automatically registers it.
package online; public class LoadDriver { public static void main(String args[]) { String driver = “oracle.jdbc.driver.OracleDriver”; try { Class.forName(driver); System.out.println(“Driver loaded”); } catch(ClassNotFoundException e1) { System.out.println(“Exception : Driver is not present”); } } } |