|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mysql.jdbc.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 boolean |
DEBUG
Should the driver generate debugging output? |
protected static int |
HOST_NAME_INDEX
Index for hostname coming out of parseHostPortPair(). |
protected static int |
PORT_NUMBER_INDEX
Index for port # coming out of parseHostPortPair(). |
static boolean |
TRACE
Should the driver generate method-call traces? |
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. |
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)
Constructs a new DriverURL, splitting the specified URL into its component parts |
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 boolean DEBUG
public static final boolean TRACE
protected static final int HOST_NAME_INDEX
protected static final int PORT_NUMBER_INDEX
Constructor Detail |
public NonRegisteringDriver() throws java.sql.SQLException
java.sql.SQLException
- if a database error occurs.Method Detail |
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 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 java.sql.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 occurs
java.sql.SQLException
- DOCUMENT ME!Driver.connect(java.lang.String, java.util.Properties)
public java.lang.String database(java.util.Properties props)
props
props
- the Properties to look for the database property.
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
url
- JDBC URL to parsedefaults
- Default properties
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
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 occursstatic int getMajorVersionInternal()
static int getMinorVersionInternal()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |