jxDBCon 0.9z

org.sourceforge.jxdbcon
Class JXDBConDriver

java.lang.Object
  |
  +--org.sourceforge.jxdbcon.JXDBConDriver
All Implemented Interfaces:
Driver, InfoKeys

public final class JXDBConDriver
extends Object
implements Driver, InfoKeys

JXDBConDriver is the interface to the DriverManager, it dispatches the openConnection requests to the appropriate sub driver. This class handles the URL syntax. Acceptable URLs look like this:

jdbc:driver:subdriver[//[[user][:password]@][host][:port][/catalog]
Optionally additional parameters can be supplied by appending a [?parameters] block. The parameters itself are of the form [parameter[=value]] and are separated by ; (semicolon)

Example URLs include: jdbc:postgresql:net//keve@localhost:9876/mydb jdbc:postgresql:net//keve@/mydb jdbc:postgresql:net For the additional properties supported by a given connection handler consult the InfoKeys interface and its subinterfaces.

Version:
$Revision: 1.11 $, $Date: 2002/04/24 21:06:02 $
Author:
Keve Müller
See Also:
DriverManager, InfoKeys, AbstractConnection

Field Summary
private static String[][] connectionTypes
          The known connection classes.
 
Fields inherited from interface org.sourceforge.jxdbcon.InfoKeys
CATALOG, DESCRIPTION, DRIVER, HOST, PASSWORD, PORT, SUBDRIVER, USER
 
Constructor Summary
JXDBConDriver()
           
 
Method Summary
 boolean acceptsURL(String url)
          Returns true if the URL's syntax is correct and a connection is registered with the type and subtype.
private  Properties breakURL(String url, Properties info)
          Split the URL into its parts and populate a Map with it.
 Connection connect(String url, Properties info)
          Connect to the URL.
private  AbstractConnection getConnection(String connClass)
          Instantiate the connection handler.
 int getMajorVersion()
          Gets the driver's major version number.
 int getMinorVersion()
          Gets the driver's minor version number.
 DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
          Gets information about the possible properties for this driver.
 boolean jdbcCompliant()
          Reports whether this driver is a genuine JDBC COMPLIANT driver.
private  String matchConnection(String driver, String subdriver)
          Match the driver/subdriver array with a known Connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionTypes

private static final String[][] connectionTypes
The known connection classes. Once there will be more, this should be made more intelligent.

Constructor Detail

JXDBConDriver

public JXDBConDriver()
Method Detail

acceptsURL

public final boolean acceptsURL(String url)
Returns true if the URL's syntax is correct and a connection is registered with the type and subtype.

Specified by:
acceptsURL in interface Driver
Parameters:
url - The URL of the database.
Returns:
true if this driver understands the given URL and has a Connection handler class registered for it.

breakURL

private final Properties breakURL(String url,
                                  Properties info)
Split the URL into its parts and populate a Map with it. First the information in the URL is parsed, then the Properties given are merged in, overriding any URL parameters.

Parameters:
url - The URL of the database.
info - The additional parameters
Returns:
null if the URL is not accepted, all parsed and specified Properties otherwise

connect

public final Connection connect(String url,
                                Properties info)
                         throws SQLException
Connect to the URL. First the URL is parsed, then the parameters in the Properties are merged in, overriding any URL parameters. Finally the Connection handler is instantiated and the connection opened.

Specified by:
connect in interface Driver
Parameters:
url - The URL of the database.
info - The additional parameters
Returns:
null if the url is not accepted
Throws:
SQLException - if the url is accepted, but the connection cannot be established
See Also:
AbstractConnection.open(java.lang.String, java.util.Properties)

getConnection

private final AbstractConnection getConnection(String connClass)
                                        throws SQLException
Instantiate the connection handler.

Throws:
SQLException - the wrapped exception if the instance could not be created

getMajorVersion

public final int getMajorVersion()
Gets the driver's major version number.

Specified by:
getMajorVersion in interface Driver
Returns:
The current version is 0.

getMinorVersion

public final int getMinorVersion()
Gets the driver's minor version number.

Specified by:
getMinorVersion in interface Driver
Returns:
The current version is 9.

getPropertyInfo

public final DriverPropertyInfo[] getPropertyInfo(String url,
                                                  Properties info)
                                           throws SQLException
Gets information about the possible properties for this driver. The connection handler for the given URL is instantiated and asked to fill the appropriate DriverPropertyInfo structure.

Specified by:
getPropertyInfo in interface Driver
Parameters:
url - The URL of the database.
info - The additional parameters
Returns:
an empty array if the URL is not accepted.
SQLException
See Also:
AbstractConnection.fillPropertyInfo(java.util.ArrayList, java.util.Properties)

jdbcCompliant

public final boolean jdbcCompliant()
Reports whether this driver is a genuine JDBC COMPLIANT driver. Returns true, in order not to break testing tools.

Specified by:
jdbcCompliant in interface Driver
Returns:
true

matchConnection

private final String matchConnection(String driver,
                                     String subdriver)
Match the driver/subdriver array with a known Connection.

Parameters:
driver - the driver
subdriver - the driver specific subprotocol
Returns:
the found connection's class name, null if no match is found.

jxDBCon 0.9z

Copyright © 2001,2002 Keve Müller; see LICENSE file for details.