Class NonRegisteringDriver

java.lang.Object
com.mysql.cj.jdbc.NonRegisteringDriver
All Implemented Interfaces:
java.sql.Driver
Direct Known Subclasses:
Driver, Driver

public class NonRegisteringDriver
extends java.lang.Object
implements java.sql.Driver
The Java SQL framework allows for multiple database drivers. Each driver should supply a class that implements the Driver interface

The DriverManager will try to load as many drivers as it can find and then for any given connection request, it will ask each driver in turn to try to connect to the target URL.

It is strongly recommended that each Driver class should be small and standalone so that the Driver class can be loaded and queried without bringing in vast quantities of supporting code.

When a Driver class is loaded, it should create an instance of itself and register it with the DriverManager. This means that a user can load and register a driver by doing Class.forName("foo.bah.Driver")

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static boolean acceptAwsProtocolOnly  
  • Constructor Summary

    Constructors 
    Constructor Description
    NonRegisteringDriver()
    Construct a new driver and register it with DriverManager
  • Method Summary

    Modifier and Type Method Description
    boolean acceptsURL​(java.lang.String url)
    Typically, drivers will return true if they understand the subprotocol specified in the URL and false if they don't.
    java.sql.Connection connect​(java.lang.String url, java.util.Properties info)
    Try to make a database connection to the given URL.
    int getMajorVersion()  
    int getMinorVersion()  
    static java.lang.String getOSName()  
    java.util.logging.Logger getParentLogger()  
    static java.lang.String getPlatform()  
    java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url, java.util.Properties info)  
    boolean jdbcCompliant()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • NonRegisteringDriver

      public NonRegisteringDriver() throws java.sql.SQLException
      Construct a new driver and register it with DriverManager
      Throws:
      java.sql.SQLException - if a database error occurs.
  • Method Details

    • getOSName

      public static java.lang.String getOSName()
    • getPlatform

      public static java.lang.String getPlatform()
    • acceptsURL

      public boolean acceptsURL​(java.lang.String url)
      Typically, drivers will return true if they understand the subprotocol specified in the URL and false if they don't. This driver's protocols start with jdbc:mysql:
      Specified by:
      acceptsURL in interface java.sql.Driver
      Parameters:
      url - the URL of the driver
      Returns:
      true if this driver accepts the given URL
      Throws:
      java.sql.SQLException - if a database access error occurs or the url is null
    • connect

      public java.sql.Connection connect​(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
      Try to make a database connection to the given URL. The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL. This will be common, as when the JDBC driverManager is asked to connect to a given URL, it passes the URL to each loaded driver in turn.

      The driver should raise an SQLException if the URL is null or if it is the right driver to connect to the given URL, but has trouble connecting to the database.

      The java.util.Properties argument can be used to pass arbitrary string tag/value pairs as connection arguments. These properties take precedence over any properties sent in the URL.

      MySQL protocol takes the form: jdbc:mysql://host:port/database

      Specified by:
      connect in interface java.sql.Driver
      Parameters:
      url - the URL of the database to connect to
      info - a list of arbitrary tag/value pairs as connection arguments
      Returns:
      a connection to the URL or null if it isn't us
      Throws:
      java.sql.SQLException - if a database access error occurs or the url is null
    • getMajorVersion

      public int getMajorVersion()
      Specified by:
      getMajorVersion in interface java.sql.Driver
    • getMinorVersion

      public int getMinorVersion()
      Specified by:
      getMinorVersion in interface java.sql.Driver
    • getPropertyInfo

      public java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
      Specified by:
      getPropertyInfo in interface java.sql.Driver
      Throws:
      java.sql.SQLException
    • jdbcCompliant

      public boolean jdbcCompliant()
      Specified by:
      jdbcCompliant in interface java.sql.Driver
    • getParentLogger

      public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
      Specified by:
      getParentLogger in interface java.sql.Driver
      Throws:
      java.sql.SQLFeatureNotSupportedException