< prev index next >

jdk/src/java.sql/share/classes/java/sql/DriverManager.java

Print this page




 432      * to which the current caller has access.
 433      *
 434      * <P><B>Note:</B> The classname of a driver can be found using
 435      * <CODE>d.getClass().getName()</CODE>
 436      *
 437      * @return the list of JDBC Drivers loaded by the caller's class loader
 438      * @see #drivers()
 439      */
 440     @CallerSensitive
 441     public static Enumeration<Driver> getDrivers() {
 442         ensureDriversInitialized();
 443 
 444         return Collections.enumeration(getDrivers(Reflection.getCallerClass()));
 445     }
 446 
 447     /**
 448      * Retrieves a Stream with all of the currently loaded JDBC drivers
 449      * to which the current caller has access.
 450      *
 451      * @return the stream of JDBC Drivers loaded by the caller's class loader
 452      * @since 1.9
 453      */
 454     @CallerSensitive
 455     public static Stream<Driver> drivers() {
 456         ensureDriversInitialized();
 457 
 458         return getDrivers(Reflection.getCallerClass()).stream();
 459     }
 460 
 461     private static List<Driver> getDrivers(Class<?> callerClass) {
 462         List<Driver> result = new ArrayList<>();
 463         // Walk through the loaded registeredDrivers.
 464         for (DriverInfo aDriver : registeredDrivers) {
 465             // If the caller does not have permission to load the driver then
 466             // skip it.
 467             if (isDriverAllowed(aDriver.driver, callerClass)) {
 468                 result.add(aDriver.driver);
 469             } else {
 470                 println("    skipping: " + aDriver.getClass().getName());
 471             }
 472         }




 432      * to which the current caller has access.
 433      *
 434      * <P><B>Note:</B> The classname of a driver can be found using
 435      * <CODE>d.getClass().getName()</CODE>
 436      *
 437      * @return the list of JDBC Drivers loaded by the caller's class loader
 438      * @see #drivers()
 439      */
 440     @CallerSensitive
 441     public static Enumeration<Driver> getDrivers() {
 442         ensureDriversInitialized();
 443 
 444         return Collections.enumeration(getDrivers(Reflection.getCallerClass()));
 445     }
 446 
 447     /**
 448      * Retrieves a Stream with all of the currently loaded JDBC drivers
 449      * to which the current caller has access.
 450      *
 451      * @return the stream of JDBC Drivers loaded by the caller's class loader
 452      * @since 9
 453      */
 454     @CallerSensitive
 455     public static Stream<Driver> drivers() {
 456         ensureDriversInitialized();
 457 
 458         return getDrivers(Reflection.getCallerClass()).stream();
 459     }
 460 
 461     private static List<Driver> getDrivers(Class<?> callerClass) {
 462         List<Driver> result = new ArrayList<>();
 463         // Walk through the loaded registeredDrivers.
 464         for (DriverInfo aDriver : registeredDrivers) {
 465             // If the caller does not have permission to load the driver then
 466             // skip it.
 467             if (isDriverAllowed(aDriver.driver, callerClass)) {
 468                 result.add(aDriver.driver);
 469             } else {
 470                 println("    skipping: " + aDriver.getClass().getName());
 471             }
 472         }


< prev index next >