Interface Driver

public interface Driver extends Object

Drivers are loaded by the DriverManager to provide connections to specific databases. A user can load and register a JDBC driver by calling Class. forName("a.specific.driver"). The DriverManager will use this driver if it can successfully connect to a given database URL.

See also: DriverManager, Connection

Methods

acceptsURL

public boolean acceptsURL(String url) throws SQLException 

This method is used to check whether the URL syntax is recognized by the driver and if it is capable of opening a connection to it. A driver usually returns true if it is able to understand the subprotocol field of the given URL.

Parameters:

url:

The URL of the database

Returns: true if this driver can connect to the given URL

connect

public Connection connect(String url, Properties info) throws SQLException

This method is used to get a Connection object for a particular database URL. The DriverManager invokes this method for all Drivers that are loaded and receives either a null if the Driver isn’t appropriate for this connection or a Connection object in the opposite case. Note that a SQLException is thrown by the Driver if it has trouble connecting to the database.

Connection arguments may be passed as tag/value pairs by way of java.util. Properties. At a minimum, user and password properties are included in the properties.

Parameters:

url:

The URL of the database to connect to

info:

A list of tag/value pairs as connection arguments

Returns: A Connection to the URL

getMajorVersion

public int getMajorVersion()

This gets the driver’s major version number.

getMinorVersion

public int getMinorVersion()

This gets the driver’s minor version number.

getPropertyInfo

public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException

This gets the necessary properties that must be provided to use the driver. The property list may vary according to the values supplied at different points in time, so it may be necessary to iterate though several calls to this method to discover all the mandatory properties.

Parameters:

url:

The URL of the database to connect to

info:

A list of tag/value pair properties

Returns: An array of DriverPropertyInfo objects; this array may be empty if no properties are required.

jdbcCompliant

public boolean jdbcCompliant()

This reports whether the driver is a genuine JDBC compliant driver.

The driver reports true only if it passes the JDBC compliance tests, meaning that it provides full support for both the JDBC API and for SQL 92 Entry Level.

Returns: true if the driver is JDBC compliant



JDBC 3. 0. JAVA Database Connectivity
JDBC 3: Java Database Connectivity
ISBN: 0764548751
EAN: 2147483647
Year: 2002
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net