net.sourceforge.jtds.jdbc

Class DefaultProperties


public final class DefaultProperties
extends java.lang.Object

Container for default property constants.

This class also provides static utility methods for Properties and Settings objects.

To add new properties to the jTDS driver, do the following:

  1. Add prop.foo and prop.desc.foo properties to Messages.properties.
  2. Add a static final default field to DefaultProperties.
  3. Update addDefaultProperties(java.util.Properties) to set the default.
  4. Update Driver.createChoicesMap() and DriverUnitTest.test_getPropertyInfo_Choices() if the property has a specific set of inputs, e.g., "true" and "false", or "1" and "2".
  5. Update Driver.createRequiredTrueMap() and DriverUnitTest.test_getPropertyInfo_Required() if the property is required.
  6. Add a new test to DefaultPropertiesTestLibrary for the new property.
Version:
$Id: DefaultProperties.java,v 1.32 2007/08/22 18:22:04 bheineman Exp $
Author:
David D. Kilzer

Field Summary

static String
APP_NAME
Default appName property.
static String
BATCH_SIZE_SQLSERVER
Default batchSize property for SQL Server.
static String
BATCH_SIZE_SYBASE
Default batchSize property for Sybase.
static String
BIND_ADDRESS
Default bindAddress property.
static String
BUFFER_DIR
Default tmpDir property.
static String
BUFFER_MAX_MEMORY
Default bufferMaxMemory property.
static String
BUFFER_MIN_PACKETS
Default bufferMinPackets property.
static String
CACHEMETA
Default cacheMetaData property.
static String
CHARSET
Default charset property.
static String
DATABASE_NAME
Default databaseName property.
static String
DOMAIN
Default domain property.
static String
INSTANCE
Default instance property.
static String
LANGUAGE
Default language property.
static String
LAST_UPDATE_COUNT
Default lastUpdateCount property.
static String
LOB_BUFFER_SIZE
Default lobBufferSize property.
static String
LOGFILE
Default logfile property.
static String
LOGIN_TIMEOUT
Default loginTimeout property.
static String
MAC_ADDRESS
Default macAddress property.
static String
MAX_STATEMENTS
Default maxStatements property.
static String
NAMED_PIPE
Default namedPipe property.
static String
NAMED_PIPE_PATH_SQLSERVER
Default namedPipePath property for SQL Server.
static String
NAMED_PIPE_PATH_SYBASE
Default namedPipePath property for Sybase.
static String
PACKET_SIZE_42
Default packetSize property for TDS 4.2.
static String
PACKET_SIZE_50
Default packetSize property for TDS 5.0.
static String
PACKET_SIZE_70_80
Default packetSize property for TDS 7.0 and TDS 8.0.
static String
PASSWORD
Default password property.
static String
PORT_NUMBER_SQLSERVER
Default portNumber property for SQL Server.
static String
PORT_NUMBER_SYBASE
Default portNumber property for Sybase.
static String
PREPARE_SQLSERVER
Default prepareSql property for SQL Server.
static String
PREPARE_SYBASE
Default prepareSql property for Sybase.
static String
PROG_NAME
Default progName property.
static String
SERVER_TYPE_SQLSERVER
Default serverType property for SQL Server.
static String
SERVER_TYPE_SYBASE
Default serverType property for Sybase.
static String
SOCKET_TIMEOUT
Default sockeTimeout property.
static String
SSL
Default ssl property.
static String
TCP_NODELAY
Default tcpNoDelay property.
static String
TDS_VERSION_42
Default tds property for TDS 4.2.
static String
TDS_VERSION_50
Default tds property for TDS 5.0.
static String
TDS_VERSION_70
Default tds property for TDS 7.0.
static String
TDS_VERSION_80
Default tds property for TDS 8.0.
static String
USECURSORS
Default useCursors property.
static String
USEJCIFS
Default useJCIFS property.
static String
USELOBS
Default useLOBs property.
static String
USER
Default user property.
static String
USE_UNICODE
Default sendStringParametersAsUnicode property.
static String
WSID
Default wsid property.
static String
XAEMULATION
Default XaEmulation property.
private static HashMap
batchSizeDefaults
Default max batch size based on server type
private static HashMap
packetSizeDefaults
Default packet size based on TDS version
private static HashMap
portNumberDefaults
Default port number based on server type
private static HashMap
prepareSQLDefaults
Default prepare SQL mode based on server type
private static HashMap
tdsDefaults
Default TDS version based on server type

Method Summary

static Properties
addDefaultProperties(Properties props)
Add default properties to the props properties object.
private static void
addDefaultPropertyIfNotSet(Properties props, String key, String defaultValue)
Sets a default property if the property is not already set.
private static void
addDefaultPropertyIfNotSet(Properties props, String key, String defaultKey, Map defaults)
Sets a default property if the property is not already set, using the defaultKey and the defaults map to determine the correct value.
static String
getNamedPipePath(int serverType)
Returns the default path for the named pipe for a given serverType.
static Integer
getServerType(String serverType)
Converts a string server type to its integer representation.
static String
getServerType(int serverType)
Converts an integer server type to its string representation.
static String
getServerTypeWithDefault(int serverType)
Same as getServerType(int), only it returns the default server type ("sqlserver") if serverType is 0.
static Integer
getTdsVersion(String tdsVersion)
Converts a string TDS version to its integer representation.

Field Details

APP_NAME

public static final String APP_NAME
Default appName property.

BATCH_SIZE_SQLSERVER

public static final String BATCH_SIZE_SQLSERVER
Default batchSize property for SQL Server.

BATCH_SIZE_SYBASE

public static final String BATCH_SIZE_SYBASE
Default batchSize property for Sybase.

BIND_ADDRESS

public static final String BIND_ADDRESS
Default bindAddress property.

BUFFER_DIR

public static final String BUFFER_DIR
Default tmpDir property.

BUFFER_MAX_MEMORY

public static final String BUFFER_MAX_MEMORY
Default bufferMaxMemory property.

BUFFER_MIN_PACKETS

public static final String BUFFER_MIN_PACKETS
Default bufferMinPackets property.

CACHEMETA

public static final String CACHEMETA
Default cacheMetaData property.

CHARSET

public static final String CHARSET
Default charset property.

DATABASE_NAME

public static final String DATABASE_NAME
Default databaseName property.

DOMAIN

public static final String DOMAIN
Default domain property.

INSTANCE

public static final String INSTANCE
Default instance property.

LANGUAGE

public static final String LANGUAGE
Default language property.

LAST_UPDATE_COUNT

public static final String LAST_UPDATE_COUNT
Default lastUpdateCount property.

LOB_BUFFER_SIZE

public static final String LOB_BUFFER_SIZE
Default lobBufferSize property.

LOGFILE

public static final String LOGFILE
Default logfile property.

LOGIN_TIMEOUT

public static final String LOGIN_TIMEOUT
Default loginTimeout property.

MAC_ADDRESS

public static final String MAC_ADDRESS
Default macAddress property.

MAX_STATEMENTS

public static final String MAX_STATEMENTS
Default maxStatements property.

NAMED_PIPE

public static final String NAMED_PIPE
Default namedPipe property.

NAMED_PIPE_PATH_SQLSERVER

public static final String NAMED_PIPE_PATH_SQLSERVER
Default namedPipePath property for SQL Server.

NAMED_PIPE_PATH_SYBASE

public static final String NAMED_PIPE_PATH_SYBASE
Default namedPipePath property for Sybase.

PACKET_SIZE_42

public static final String PACKET_SIZE_42
Default packetSize property for TDS 4.2.

PACKET_SIZE_50

public static final String PACKET_SIZE_50
Default packetSize property for TDS 5.0.

PACKET_SIZE_70_80

public static final String PACKET_SIZE_70_80
Default packetSize property for TDS 7.0 and TDS 8.0.

PASSWORD

public static final String PASSWORD
Default password property.

PORT_NUMBER_SQLSERVER

public static final String PORT_NUMBER_SQLSERVER
Default portNumber property for SQL Server.

PORT_NUMBER_SYBASE

public static final String PORT_NUMBER_SYBASE
Default portNumber property for Sybase.

PREPARE_SQLSERVER

public static final String PREPARE_SQLSERVER
Default prepareSql property for SQL Server.

PREPARE_SYBASE

public static final String PREPARE_SYBASE
Default prepareSql property for Sybase.

PROG_NAME

public static final String PROG_NAME
Default progName property.

SERVER_TYPE_SQLSERVER

public static final String SERVER_TYPE_SQLSERVER
Default serverType property for SQL Server.

SERVER_TYPE_SYBASE

public static final String SERVER_TYPE_SYBASE
Default serverType property for Sybase.

SOCKET_TIMEOUT

public static final String SOCKET_TIMEOUT
Default sockeTimeout property.

SSL

public static final String SSL
Default ssl property.

TCP_NODELAY

public static final String TCP_NODELAY
Default tcpNoDelay property.

TDS_VERSION_42

public static final String TDS_VERSION_42
Default tds property for TDS 4.2.

TDS_VERSION_50

public static final String TDS_VERSION_50
Default tds property for TDS 5.0.

TDS_VERSION_70

public static final String TDS_VERSION_70
Default tds property for TDS 7.0.

TDS_VERSION_80

public static final String TDS_VERSION_80
Default tds property for TDS 8.0.

USECURSORS

public static final String USECURSORS
Default useCursors property.

USEJCIFS

public static final String USEJCIFS
Default useJCIFS property.

USELOBS

public static final String USELOBS
Default useLOBs property.

USER

public static final String USER
Default user property.

USE_UNICODE

public static final String USE_UNICODE
Default sendStringParametersAsUnicode property.

WSID

public static final String WSID
Default wsid property.

XAEMULATION

public static final String XAEMULATION
Default XaEmulation property.

batchSizeDefaults

private static final HashMap batchSizeDefaults
Default max batch size based on server type

packetSizeDefaults

private static final HashMap packetSizeDefaults
Default packet size based on TDS version

portNumberDefaults

private static final HashMap portNumberDefaults
Default port number based on server type

prepareSQLDefaults

private static final HashMap prepareSQLDefaults
Default prepare SQL mode based on server type

tdsDefaults

private static final HashMap tdsDefaults
Default TDS version based on server type

Method Details

addDefaultProperties

public static Properties addDefaultProperties(Properties props)
Add default properties to the props properties object.
Parameters:
props - The properties object.
Returns:
The updated props object, or null if the serverType property is not set.

addDefaultPropertyIfNotSet

private static void addDefaultPropertyIfNotSet(Properties props,
                                               String key,
                                               String defaultValue)
Sets a default property if the property is not already set.
Parameters:
props - The properties object.
key - The message key to set.
defaultValue - The default value to set.

addDefaultPropertyIfNotSet

private static void addDefaultPropertyIfNotSet(Properties props,
                                               String key,
                                               String defaultKey,
                                               Map defaults)
Sets a default property if the property is not already set, using the defaultKey and the defaults map to determine the correct value.
Parameters:
props - The properties object.
key - The message key to set.
defaultKey - The key whose value determines which default value to set from defaults.
defaults - The mapping of defaultKey values to the correct key value to set.

getNamedPipePath

public static String getNamedPipePath(int serverType)
Returns the default path for the named pipe for a given serverType.
Returns:
default named pipe path

getServerType

public static Integer getServerType(String serverType)
Converts a string server type to its integer representation.
Parameters:
serverType - the server type as a string
Returns:
the server type as an integer if known or null if unknown

getServerType

public static String getServerType(int serverType)
Converts an integer server type to its string representation.
Parameters:
serverType - the server type as an int
Returns:
the server type as a string if known, or null if unknown

getServerTypeWithDefault

public static String getServerTypeWithDefault(int serverType)
Same as getServerType(int), only it returns the default server type ("sqlserver") if serverType is 0.
Parameters:
serverType - integer server type or 0 for default
Returns:
the server type as a string if known or "sqlserver" if unknown

getTdsVersion

public static Integer getTdsVersion(String tdsVersion)
Converts a string TDS version to its integer representation.
Parameters:
tdsVersion - The TDS version as a string.
Returns:
The TDS version as an integer if known, or null if unknown.

Generated on June 12 2008