Class DriverManagerAccessor


  • public class DriverManagerAccessor
    extends java.lang.Object
    Class that provides access to DriverManager.

    DriverManager is not compatible with a modular environment, as it does no allow direct access to driver classes that the callers class loader cannot load. This class allows access to DriverManager by being forced into a cl that does have access and then invoking the DriverManager methods.

    This is a horrible hack.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.sql.Connection getConnection​(java.lang.String jdbcURL)
      Delegates to DriverManager.getConnection(String).
      static java.sql.Connection getConnection​(java.lang.String jdbcURL, java.lang.String userName, java.lang.String password)
      Delegates to DriverManager.getConnection(String, String, String).
      private static java.sql.Connection getRealConnection​(java.lang.String jdbcURL)  
      private static java.sql.Connection getRealConnection​(java.lang.String jdbcURL, java.lang.String userName, java.lang.String password)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DriverManagerAccessor

        public DriverManagerAccessor()
    • Method Detail

      • getConnection

        public static java.sql.Connection getConnection​(java.lang.String jdbcURL,
                                                        java.lang.String userName,
                                                        java.lang.String password)
                                                 throws java.sql.SQLException
        Delegates to DriverManager.getConnection(String, String, String). If this fails it attempts to load a class into the class loader cl and tries again.
        Parameters:
        jdbcURL - The JDBC url
        userName - The username
        password - The password
        Returns:
        A database connection
        Throws:
        java.sql.SQLException
      • getRealConnection

        private static java.sql.Connection getRealConnection​(java.lang.String jdbcURL,
                                                             java.lang.String userName,
                                                             java.lang.String password)
                                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getConnection

        public static java.sql.Connection getConnection​(java.lang.String jdbcURL)
                                                 throws java.sql.SQLException
        Delegates to DriverManager.getConnection(String). If this fails it attempts to load a class into the class loader cl and tries again.
        Parameters:
        jdbcURL - The JDBC url
        Returns:
        A database connection
        Throws:
        java.sql.SQLException
      • getRealConnection

        private static java.sql.Connection getRealConnection​(java.lang.String jdbcURL)
                                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException