unity.jdbc
Class UnityDriver

java.lang.Object
  extended by unity.jdbc.UnityDriver
All Implemented Interfaces:
java.sql.Driver

public class UnityDriver
extends java.lang.Object
implements java.sql.Driver

Unity implements the java.sql.Driver interface and may be used like any other JDBC driver.

The UnityJDBC driver determines if it is required based on the URL. The URL should be of the form: jdbc:Unity://mypath/sources.xml
where mypath is an absolute path to the sources.xml file that is accessible to the driver. Inside the sources.xml file is information on each JDBC-accessible source that can be queried by the UnityJDBC driver. The format of this file is as follows:

 
  
 jdbc:microsoft:sqlserver://XXX.cs.uiowa.edu:1433;DatabaseName=TPCD1;User=YYY;Password=ZZZ
 com.microsoft.jdbc.sqlserver.SQLServerDriver
 Tests/xspec/TPC2.xml  
 jdbc:microsoft:sqlserver://AAA.cs.uiowa.edu:1433;DatabaseName=TPCD2;User=BBB;Password=CCC
 com.microsoft.jdbc.sqlserver.SQLServerDriver
 Tests/xspec/TPC1.xml  
 
 

The URL is the JDBC URL that would be used to connect to the source. The JDBC driver to connect to the source must be in the classpath. The XSPEC element contains an absolute or relative path to an XML file describing the data source characteristics. More information can be found in the description of

See Also:
UnityExtractor., DriverManager, Connection, UnityConnection

Field Summary
static int _MAJORVERSION
           
static int _MINORVERSION
           
static boolean DEBUG
           
static java.lang.String DRIVER_NAME
           
 
Constructor Summary
UnityDriver()
           
 
Method Summary
 boolean acceptsURL(java.lang.String url)
          Retrieves whether the driver thinks that it can open a connection to the given URL.
 java.sql.Connection connect(java.lang.String url, java.util.Properties info)
          Attempts to make a database connection to the given URL.
 int getMajorVersion()
          Retrieves the driver's major version number.
 int getMinorVersion()
          Gets the driver's minor version number.
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info)
          Gets information about the possible properties for this driver.
 boolean jdbcCompliant()
          Reports whether this driver is a genuine JDBC CompliantTM driver.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_MAJORVERSION

public static final int _MAJORVERSION
See Also:
Constant Field Values

_MINORVERSION

public static final int _MINORVERSION
See Also:
Constant Field Values

DRIVER_NAME

public static java.lang.String DRIVER_NAME

DEBUG

public static boolean DEBUG
Constructor Detail

UnityDriver

public UnityDriver()
            throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

connect

public java.sql.Connection connect(java.lang.String url,
                                   java.util.Properties info)
                            throws java.sql.SQLException
Attempts to make a database connection to the given URL. The driver returns "null" if it realizes it is the wrong kind of driver to connect to the given URL.

The driver throws 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. The only properties supported by UnityJDBC are:
connectNow which may be either true or false. If true, the driver connects to all sources listed in the sources.xml file immediately. If false, connection occurs on demand as needed by queries. The default is false.

Specified by:
connect in interface java.sql.Driver
Parameters:
url - the URL of the sources.xml to read connection information (must be locally accessible file)
info - a list of arbitrary string tag/value pairs as connection arguments.
Returns:
a Connection object that represents a connection to the URL. Actually returns UnityConnection object.
Throws:
java.sql.SQLException - if a database access error occurs

acceptsURL

public boolean acceptsURL(java.lang.String url)
                   throws java.sql.SQLException
Retrieves whether the driver thinks that it can open a connection to the given URL. Typically drivers will return true if they understand the subprotocol specified in the URL and false if they do not.

Specified by:
acceptsURL in interface java.sql.Driver
Parameters:
url - the URL of the database
Returns:
true if this driver understands the given URL; false otherwise
Throws:
java.sql.SQLException - if a database access error occurs

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
                                                     java.util.Properties info)
                                              throws java.sql.SQLException
Gets information about the possible properties for this driver.

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. Note that depending on the values the human has supplied so far, additional values may become necessary, so it may be necessary to iterate though several calls to the getPropertyInfo method.

Note: Not currently supported.

Specified by:
getPropertyInfo in interface java.sql.Driver
Parameters:
url - the URL of the database to which to connect
info - a proposed list of tag/value pairs that will be sent on connect open
Returns:
an array of DriverPropertyInfo objects describing possible properties. This array may be an empty array if no properties are required.
Throws:
java.sql.SQLException - if a database access error occurs

getMajorVersion

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

Specified by:
getMajorVersion in interface java.sql.Driver
Returns:
this driver's major version number

getMinorVersion

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

Specified by:
getMinorVersion in interface java.sql.Driver
Returns:
this driver's minor version number

jdbcCompliant

public boolean jdbcCompliant()
Reports whether this driver is a genuine JDBC CompliantTM driver. A driver may only report true here if it passes the JDBC compliance tests; otherwise it is required to return false.

The UnityJDBC driver currently returns false although it supports most of SQL 92 Entry Level.

Specified by:
jdbcCompliant in interface java.sql.Driver
Returns:
true if this driver is JDBC Compliant; false otherwise