Class DefaultProperties

java.lang.Object
net.sourceforge.jtds.jdbc.DefaultProperties

public final class DefaultProperties extends 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.2.1 2009-08-07 14:02:09 ickzon Exp $
Author:
David D. Kilzer
  • Field Details

  • Constructor Details

    • DefaultProperties

      public DefaultProperties()
  • 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.
      Parameters:
      serverType - Driver.SQLSERVER or Driver.SYBASE or 0 (default)
      Returns:
      default named pipe path
      Throws:
      IllegalArgumentException - if an invalid serverType is given
    • 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
    • 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
    • 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.