|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mysql.jdbc.NonRegisteringDriver
public class NonRegisteringDriver
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")
org.gjt.mm.mysql.Connection
,
Driver
Field Summary | |
---|---|
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 |
NUM_HOSTS_PROPERTY_KEY
|
static java.lang.String |
PASSWORD_PROPERTY_KEY
Key used to retreive the password value from the properties instance passed to the driver. |
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 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. |
Constructor Summary | |
---|---|
NonRegisteringDriver()
Construct a new driver and register it with DriverManager |
Method Summary | |
---|---|
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 |
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 |
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 |
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public NonRegisteringDriver() throws java.sql.SQLException
java.sql.SQLException
- if a database error occurs.Method Detail |
---|
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 driver
java.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 arguments
java.sql.SQLException
- if a database access error occursDriver.connect(java.lang.String, java.util.Properties)
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 from
public java.lang.String property(java.lang.String name, java.util.Properties props)
props
name
- the property nameprops
- the property instance to look in
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |