publicclassDriverManager{...// List of registered JDBC driversprivatefinalstaticCopyOnWriteArrayList<DriverInfo> registeredDrivers =newCopyOnWriteArrayList<>();...publicstaticsynchronizedvoidregisterDriver(java.sql.Driver driver,DriverAction da)throwsSQLException{/* Register the driver if it has not already been added to our list */if(driver !=null){
registeredDrivers.addIfAbsent(newDriverInfo(driver, da));}else{// This is for compatibility with the original DriverManagerthrownewNullPointerException();}println("registerDriver: "+ driver);}publicstaticConnectiongetConnection(String url,String user,String password)throwsSQLException{java.util.Properties info =newjava.util.Properties();if(user !=null){
info.put("user", user);}if(password !=null){
info.put("password", password);}return(getConnection(url, info,Reflection.getCallerClass()));}}classDriverInfo{finalDriver driver;DriverAction da;DriverInfo(Driver driver,DriverAction action){this.driver = driver;
da = action;}}