Class NonRegisteringDriver
- All Implemented Interfaces:
java.sql.Driver
public class NonRegisteringDriver
extends java.lang.Object
implements java.sql.Driver
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()
-
Field Details
-
acceptAwsProtocolOnly
protected static boolean acceptAwsProtocolOnly
-
-
Constructor Details
-
NonRegisteringDriver
public NonRegisteringDriver() throws java.sql.SQLExceptionConstruct 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 interfacejava.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.SQLExceptionTry 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 interfacejava.sql.Driver
- Parameters:
url
- the URL of the database to connect toinfo
- 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 isnull
-
getMajorVersion
public int getMajorVersion()- Specified by:
getMajorVersion
in interfacejava.sql.Driver
-
getMinorVersion
public int getMinorVersion()- Specified by:
getMinorVersion
in interfacejava.sql.Driver
-
getPropertyInfo
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException- Specified by:
getPropertyInfo
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
jdbcCompliant
public boolean jdbcCompliant()- Specified by:
jdbcCompliant
in interfacejava.sql.Driver
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException- Specified by:
getParentLogger
in interfacejava.sql.Driver
- Throws:
java.sql.SQLFeatureNotSupportedException
-