com.mysql.jdbc
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")
org.gjt.mm.mysql.Connection
,
Driver
Modifier and Type | Class and Description |
---|---|
(package private) static class |
NonRegisteringDriver.ConnectionPhantomReference |
Modifier and Type | Field and Description |
---|---|
protected static java.util.concurrent.ConcurrentHashMap<NonRegisteringDriver.ConnectionPhantomReference,NonRegisteringDriver.ConnectionPhantomReference> |
connectionPhantomRefs |
static java.lang.String |
DBNAME_PROPERTY_KEY
Key used to retreive the database value from the properties instance
passed to the driver.
|
static boolean |
DEBUG
Should the driver generate debugging output?
|
static int |
HOST_NAME_INDEX
Index for hostname coming out of parseHostPortPair().
|
static java.lang.String |
HOST_PROPERTY_KEY
Key used to retreive the hostname value from the properties instance
passed to the driver.
|
static java.lang.String |
LICENSE |
static java.lang.String |
NAME |
static java.lang.String |
NUM_HOSTS_PROPERTY_KEY |
static java.lang.String |
OS |
static java.lang.String |
PASSWORD_PROPERTY_KEY
Key used to retreive the password value from the properties instance
passed to the driver.
|
static java.lang.String |
PATH_PROPERTY_KEY |
static java.lang.String |
PLATFORM |
static int |
PORT_NUMBER_INDEX
Index for port # coming out of parseHostPortPair().
|
static java.lang.String |
PORT_PROPERTY_KEY
Key used to retreive the port number value from the properties instance
passed to the driver.
|
static java.lang.String |
PROPERTIES_TRANSFORM_KEY |
static java.lang.String |
PROTOCOL_PROPERTY_KEY |
protected static java.lang.ref.ReferenceQueue<ConnectionImpl> |
refQueue |
static java.lang.String |
RUNTIME_VENDOR |
static java.lang.String |
RUNTIME_VERSION |
static boolean |
TRACE
Should the driver generate method-call traces?
|
static java.lang.String |
USE_CONFIG_PROPERTY_KEY |
static java.lang.String |
USER_PROPERTY_KEY
Key used to retreive the username value from the properties instance
passed to the driver.
|
static java.lang.String |
VERSION |
Constructor and Description |
---|
NonRegisteringDriver()
Construct a new driver and register it with DriverManager
|
Modifier and Type | Method and 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.
|
protected java.sql.Connection |
connectReplicationConnection(java.lang.String url,
java.util.Properties info) |
java.lang.String |
database(java.util.Properties props)
Returns the database property from
props |
static java.util.Properties |
expandHostKeyValues(java.lang.String host)
Expands hosts of the form address=(protocol=tcp)(host=localhost)(port=3306)
into a java.util.Properties.
|
int |
getMajorVersion()
Gets the drivers major version number
|
(package private) static int |
getMajorVersionInternal()
Gets the drivers major version number
|
int |
getMinorVersion()
Get the drivers minor version number
|
(package private) static int |
getMinorVersionInternal()
Get the drivers minor version number
|
static java.lang.String |
getOSName() |
static java.lang.String |
getPlatform() |
java.sql.DriverPropertyInfo[] |
getPropertyInfo(java.lang.String url,
java.util.Properties info)
The getPropertyInfo method is intended to allow a generic GUI tool to
discover what properties it should prompt a human for in order to get
enough information to connect to a database.
|
java.lang.String |
host(java.util.Properties props)
Returns the hostname property
|
static boolean |
isHostPropertiesList(java.lang.String host) |
boolean |
jdbcCompliant()
Report whether the driver is a genuine JDBC compliant driver.
|
protected static java.lang.String[] |
parseHostPortPair(java.lang.String hostPortPair)
Parses hostPortPair in the form of [host][:port] into an array, with the
element of index HOST_NAME_INDEX being the host (or null if not
specified), and the element of index PORT_NUMBER_INDEX being the port (or
null if not specified).
|
java.util.Properties |
parseURL(java.lang.String url,
java.util.Properties defaults) |
int |
port(java.util.Properties props)
Returns the port number property
|
java.lang.String |
property(java.lang.String name,
java.util.Properties props)
Returns the given property from
props |
protected static void |
trackConnection(Connection newConn) |
protected static final java.util.concurrent.ConcurrentHashMap<NonRegisteringDriver.ConnectionPhantomReference,NonRegisteringDriver.ConnectionPhantomReference> connectionPhantomRefs
protected static final java.lang.ref.ReferenceQueue<ConnectionImpl> refQueue
public static final java.lang.String OS
public static final java.lang.String PLATFORM
public static final java.lang.String LICENSE
public static final java.lang.String RUNTIME_VENDOR
public static final java.lang.String RUNTIME_VERSION
public static final java.lang.String VERSION
public static final java.lang.String NAME
public static final java.lang.String DBNAME_PROPERTY_KEY
public static final boolean DEBUG
public static final int HOST_NAME_INDEX
public static final java.lang.String HOST_PROPERTY_KEY
public static final java.lang.String NUM_HOSTS_PROPERTY_KEY
public static final java.lang.String PASSWORD_PROPERTY_KEY
public static final int PORT_NUMBER_INDEX
public static final java.lang.String PORT_PROPERTY_KEY
public static final java.lang.String PROPERTIES_TRANSFORM_KEY
public static final boolean TRACE
public static final java.lang.String USE_CONFIG_PROPERTY_KEY
public static final java.lang.String USER_PROPERTY_KEY
public static final java.lang.String PROTOCOL_PROPERTY_KEY
public static final java.lang.String PATH_PROPERTY_KEY
public NonRegisteringDriver() throws java.sql.SQLException
java.sql.SQLException
- if a database error occurs.public static java.lang.String getOSName()
public static java.lang.String getPlatform()
static int getMajorVersionInternal()
static int getMinorVersionInternal()
protected static java.lang.String[] parseHostPortPair(java.lang.String hostPortPair) throws java.sql.SQLException
hostPortPair
- host and port in form of of [host][:port]java.sql.SQLException
- if a parse error occurspublic boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
acceptsURL
in interface java.sql.Driver
url
- the URL of the driverjava.sql.SQLException
- if a database-access error occursDriver.acceptsURL(java.lang.String)
public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
The driver should raise an SQLException 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.
My protocol takes the form:
jdbc:mysql://host:port/database
connect
in interface java.sql.Driver
url
- the URL of the database to connect toinfo
- a list of arbitrary tag/value pairs as connection argumentsjava.sql.SQLException
- if a database access error occursDriver.connect(java.lang.String, java.util.Properties)
protected static void trackConnection(Connection newConn)
protected java.sql.Connection connectReplicationConnection(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String database(java.util.Properties props)
props
props
- the Properties to look for the database property.public int getMajorVersion()
getMajorVersion
in interface java.sql.Driver
public int getMinorVersion()
getMinorVersion
in interface java.sql.Driver
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
Note that depending on the values the human has supplied so far, additional values may become necessary, so it may be necessary to iterate through several calls to getPropertyInfo
getPropertyInfo
in interface java.sql.Driver
url
- the Url of the database to connect toinfo
- a proposed list of tag/value pairs that will be sent on
connect open.java.sql.SQLException
- if a database-access error occursDriver.getPropertyInfo(java.lang.String, java.util.Properties)
public java.lang.String host(java.util.Properties props)
props
- the java.util.Properties instance to retrieve the hostname
from.public boolean jdbcCompliant()
MySQL is not SQL92 compliant
jdbcCompliant
in interface java.sql.Driver
public java.util.Properties parseURL(java.lang.String url, java.util.Properties defaults) throws java.sql.SQLException
java.sql.SQLException
public int port(java.util.Properties props)
props
- the properties to get the port number frompublic java.lang.String property(java.lang.String name, java.util.Properties props)
props
name
- the property nameprops
- the property instance to look inpublic static java.util.Properties expandHostKeyValues(java.lang.String host)
public static boolean isHostPropertiesList(java.lang.String host)