net.sourceforge.jtds.jdbc

Class Driver

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 2007/08/02 22:35:27 bheineman Exp $
Authors:
Brian Heineman
Mike Hutchinson
Alin Sinpalean
See Also:
java.sql.Driver

Field Summary

static String
APPNAME
static String
BATCHSIZE
static String
BINDADDRESS
static String
BUFFERDIR
static String
BUFFERMAXMEMORY
static String
BUFFERMINPACKETS
static String
CACHEMETA
static String
CHARSET
static String
DATABASENAME
static String
DOMAIN
static String
INSTANCE
static boolean
JDBC3
Set if the JDBC specification to implement is 3.0 or greater.
static String
LANGUAGE
static String
LASTUPDATECOUNT
static String
LOBBUFFER
static String
LOGFILE
static String
LOGINTIMEOUT
static String
MACADDRESS
(package private) static int
MAJOR_VERSION
Driver major version.
static String
MAXSTATEMENTS
(package private) static int
MINOR_VERSION
Driver minor version.
(package private) static String
MISC_VERSION
Driver version miscellanea (e.g "-rc2", ".1" or null).
static String
NAMEDPIPE
static String
PACKETSIZE
static String
PASSWORD
static String
PORTNUMBER
static String
PREPARESQL
static String
PROGNAME
static String
SENDSTRINGPARAMETERSASUNICODE
static String
SERVERNAME
static String
SERVERTYPE
static String
SOTIMEOUT
static int
SQLSERVER
Microsoft SQL Server.
static String
SSL
static int
SYBASE
Sybase ASE.
static String
TCPNODELAY
static String
TDS
static int
TDS42
TDS 4.2 protocol (SQL Server 6.5 and later and Sybase 9 and later).
static int
TDS50
TDS 5.0 protocol (Sybase 10 and later).
static int
TDS70
TDS 7.0 protocol (SQL Server 7.0 and later).
static int
TDS80
TDS 8.0 protocol (SQL Server 2000 and later)
static int
TDS81
TDS 8.1 protocol (SQL Server 2000 SP1 and later).
static String
USECURSORS
static String
USEJCIFS
static String
USELOBS
static String
USENTLMV2
static String
USER
static String
WSID
static String
XAEMULATION
private static String
driverPrefix
URL prefix used by the driver (i.e jdbc:jtds:).

Method Summary

boolean
acceptsURL(String url)
Connection
connect(String url, Properties info)
private static Map
createChoicesMap()
Creates a map of driver properties whose choices field should be set when calling getPropertyInfo(String,Properties).
private static Map
createRequiredTrueMap()
Creates a map of driver properties that should be marked as required when calling getPropertyInfo(String,Properties).
int
getMajorVersion()
int
getMinorVersion()
DriverPropertyInfo[]
getPropertyInfo(String url, Properties props)
static String
getVersion()
Returns the driver version.
boolean
jdbcCompliant()
static void
main(String[] args)
private static int
nextToken(String url, int pos, StringBuffer token)
Extract the next lexical token from the URL.
private static Properties
parseURL(String url, Properties info)
Parse the driver URL and extract the properties.
private Properties
setupConnectProperties(String url, Properties info)
Sets up properties for the connect(String, java.util.Properties) method.
String
toString()
Returns the string form of the object.

Field Details

APPNAME

public static final String APPNAME

BATCHSIZE

public static final String BATCHSIZE

BINDADDRESS

public static final String BINDADDRESS

BUFFERDIR

public static final String BUFFERDIR

BUFFERMAXMEMORY

public static final String BUFFERMAXMEMORY

BUFFERMINPACKETS

public static final String BUFFERMINPACKETS

CACHEMETA

public static final String CACHEMETA

CHARSET

public static final String CHARSET

DATABASENAME

public static final String DATABASENAME

DOMAIN

public static final String DOMAIN

INSTANCE

public static final String INSTANCE

JDBC3

public static final boolean JDBC3
Set if the JDBC specification to implement is 3.0 or greater.

LANGUAGE

public static final String LANGUAGE

LASTUPDATECOUNT

public static final String LASTUPDATECOUNT

LOBBUFFER

public static final String LOBBUFFER

LOGFILE

public static final String LOGFILE

LOGINTIMEOUT

public static final String LOGINTIMEOUT

MACADDRESS

public static final String MACADDRESS

MAJOR_VERSION

(package private) static final int MAJOR_VERSION
Driver major version.
Field Value:
1

MAXSTATEMENTS

public static final String MAXSTATEMENTS

MINOR_VERSION

(package private) static final int MINOR_VERSION
Driver minor version.
Field Value:
2

MISC_VERSION

(package private) static final String MISC_VERSION
Driver version miscellanea (e.g "-rc2", ".1" or null).

NAMEDPIPE

public static final String NAMEDPIPE

PACKETSIZE

public static final String PACKETSIZE

PASSWORD

public static final String PASSWORD

PORTNUMBER

public static final String PORTNUMBER

PREPARESQL

public static final String PREPARESQL

PROGNAME

public static final String PROGNAME

SENDSTRINGPARAMETERSASUNICODE

public static final String SENDSTRINGPARAMETERSASUNICODE

SERVERNAME

public static final String SERVERNAME

SERVERTYPE

public static final String SERVERTYPE

SOTIMEOUT

public static final String SOTIMEOUT

SQLSERVER

public static final int SQLSERVER
Microsoft SQL Server.
Field Value:
1

SSL

public static final String SSL

SYBASE

public static final int SYBASE
Sybase ASE.
Field Value:
2

TCPNODELAY

public static final String TCPNODELAY

TDS

public static final String TDS

TDS42

public static final int TDS42
TDS 4.2 protocol (SQL Server 6.5 and later and Sybase 9 and later).
Field Value:
1

TDS50

public static final int TDS50
TDS 5.0 protocol (Sybase 10 and later).
Field Value:
2

TDS70

public static final int TDS70
TDS 7.0 protocol (SQL Server 7.0 and later).
Field Value:
3

TDS80

public static final int TDS80
TDS 8.0 protocol (SQL Server 2000 and later)
Field Value:
4

TDS81

public static final int TDS81
TDS 8.1 protocol (SQL Server 2000 SP1 and later).
Field Value:
5

USECURSORS

public static final String USECURSORS

USEJCIFS

public static final String USEJCIFS

USELOBS

public static final String USELOBS

USENTLMV2

public static final String USENTLMV2

USER

public static final String USER

WSID

public static final String WSID

XAEMULATION

public static final String XAEMULATION

driverPrefix

private static String driverPrefix
URL prefix used by the driver (i.e jdbc:jtds:).

Method Details

acceptsURL

public boolean acceptsURL(String url)
            throws SQLException

connect

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

createChoicesMap

private static 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 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.

getMajorVersion

public int getMajorVersion()

getMinorVersion

public int getMinorVersion()

getPropertyInfo

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

getVersion

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

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

Returns:
the driver version

jdbcCompliant

public boolean jdbcCompliant()

main

public static void main(String[] args)

nextToken

private static int nextToken(String url,
                             int pos,
                             StringBuffer 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.

parseURL

private static Properties parseURL(String url,
                                   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

setupConnectProperties

private Properties setupConnectProperties(String url,
                                          Properties info)
            throws 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

toString

public 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

Returns:
the driver version

Generated on September 18 2009