Class Driver

  • All Implemented Interfaces:
    java.sql.Driver

    public class Driver
    extends java.lang.Object
    implements java.sql.Driver
    jTDS implementation of the java.sql.Driver interface.

    Implementation note:

    1. Property text names and descriptions are loaded from an external file resource. This allows the actual names and descriptions to be changed or localised without impacting this code.
    2. The way in which the URL is parsed and converted to properties is rather different from the original jTDS Driver class. See parseURL and Connection.unpackProperties methods for more detail.
    Version:
    $Id: Driver.java,v 1.70.2.4 2009-12-30 11:19:40 ickzon Exp $
    Author:
    Brian Heineman, Mike Hutchinson, Alin Sinpalean
    See Also:
    Driver
    • Constructor Detail

      • Driver

        public Driver()
    • Method Detail

      • getMajorVersion

        public int getMajorVersion()
        Specified by:
        getMajorVersion in interface java.sql.Driver
      • getMinorVersion

        public int getMinorVersion()
        Specified by:
        getMinorVersion in interface java.sql.Driver
      • getVersion

        public static final java.lang.String getVersion()
        Returns the driver version.

        Per [908906] 0.7: Static Version information, please.

        Returns:
        the driver version
      • toString

        public java.lang.String toString()
        Returns the string form of the object.

        Per [887120] DriverVersion.getDriverVersion(); this will return a short version name.

        Added back to driver per [1006449] 0.9rc1: Driver version broken

        Overrides:
        toString in class java.lang.Object
        Returns:
        the driver version
      • jdbcCompliant

        public boolean jdbcCompliant()
        Specified by:
        jdbcCompliant in interface java.sql.Driver
      • acceptsURL

        public boolean acceptsURL​(java.lang.String url)
                           throws java.sql.SQLException
        Specified by:
        acceptsURL in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • connect

        public java.sql.Connection connect​(java.lang.String url,
                                           java.util.Properties info)
                                    throws java.sql.SQLException
        Specified by:
        connect in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • getPropertyInfo

        public java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url,
                                                             java.util.Properties props)
                                                      throws java.sql.SQLException
        Specified by:
        getPropertyInfo in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • setupConnectProperties

        private java.util.Properties setupConnectProperties​(java.lang.String url,
                                                            java.util.Properties info)
                                                     throws java.sql.SQLException
        Sets up properties for the connect(String, java.util.Properties) method.
        Parameters:
        url - the URL of the database to which to connect
        info - a list of arbitrary string tag/value pairs as connection arguments.
        Returns:
        the set of properties for the connection
        Throws:
        java.sql.SQLException - if an error occurs parsing the URL
      • createChoicesMap

        private static java.util.Map createChoicesMap()
        Creates a map of driver properties whose choices field should be set when calling getPropertyInfo(String, Properties).

        The values in the map are the String[] objects that should be set to the choices field.

        Returns:
        The map of DriverPropertyInfo objects whose choices should be set.
      • createRequiredTrueMap

        private static java.util.Map createRequiredTrueMap()
        Creates a map of driver properties that should be marked as required when calling getPropertyInfo(String, Properties).

        Note that only the key of the map is used to determine whether the required field should be set to true. If the key does not exist in the map, then the required field is set to false.

        Returns:
        The map of DriverPropertyInfo objects where required should be set to true.
      • parseURL

        private static java.util.Properties parseURL​(java.lang.String url,
                                                     java.util.Properties info)
        Parse the driver URL and extract the properties.
        Parameters:
        url - the URL to parse
        info - any existing properties already loaded in a Properties object
        Returns:
        the URL properties as a Properties object
      • nextToken

        private static int nextToken​(java.lang.String url,
                                     int pos,
                                     java.lang.StringBuilder token)
        Extract the next lexical token from the URL.
        Parameters:
        url - The URL being parsed
        pos - The current position in the URL string.
        token - The buffer containing the extracted token.
        Returns:
        The updated position as an int.
      • main

        public static void main​(java.lang.String[] args)
      • getParentLogger

        public java.util.logging.Logger getParentLogger()
                                                 throws java.sql.SQLFeatureNotSupportedException
        Specified by:
        getParentLogger in interface java.sql.Driver
        Throws:
        java.sql.SQLFeatureNotSupportedException