MSSqlServerInfo (jTDS API)
Date: 2013-06-08

net.sourceforge.jtds.jdbc

## Class MSSqlServerInfo

- java.lang.Object
- - net.sourceforge.jtds.jdbc.MSSqlServerInfo

-     public class MSSqlServerInfo
      extends java.lang.Object

  This class communicates with SQL Server 2k to determine what ports its instances are listening to. It does this by sending a UDP packet with the byte 0x02 in it, and parsing the response.

  An example of the return packet format is as follows:

       < 00000000 05 ea 00 53 65 72 76 65 72 4e 61 6d 65 3b 42 52 # ...ServerName;BR
       < 00000010 49 4e 4b 4c 45 59 3b 49 6e 73 74 61 6e 63 65 4e # INKLEY;InstanceN
       < 00000020 61 6d 65 3b 4d 53 53 51 4c 53 45 52 56 45 52 3b # ame;MSSQLSERVER;
       < 00000030 49 73 43 6c 75 73 74 65 72 65 64 3b 4e 6f 3b 56 # IsClustered;No;V
       < 00000040 65 72 73 69 6f 6e 3b 38 2e 30 30 2e 31 39 34 3b # ersion;8.00.194;
       < 00000050 74 63 70 3b 31 34 33 33 3b 6e 70 3b 5c 5c 42 52 # tcp;1433;np;\\BR
       < 00000060 49 4e 4b 4c 45 59 5c 70 69 70 65 5c 73 71 6c 5c # INKLEY\pipe\sql\
       < 00000070 71 75 65 72 79 3b 3b 53 65 72 76 65 72 4e 61 6d # query;;ServerNam
       < 00000080 65 3b 42 52 49 4e 4b 4c 45 59 3b 49 6e 73 74 61 # e;BRINKLEY;Insta
       < 00000090 6e 63 65 4e 61 6d 65 3b 44 4f 47 3b 49 73 43 6c # nceName;DOG;IsCl
       < 000000a0 75 73 74 65 72 65 64 3b 4e 6f 3b 56 65 72 73 69 # ustered;No;Versi
       < 000000b0 6f 6e 3b 38 2e 30 30 2e 31 39 34 3b 74 63 70 3b # on;8.00.194;tcp;
       < 000000c0 33 35 34 36 3b 6e 70 3b 5c 5c 42 52 49 4e 4b 4c # 3546;np;\\BRINKL
       < 000000d0 45 59 5c 70 69 70 65 5c 4d 53 53 51 4c 24 44 4f # EY\pipe\MSSQL$DO
       < 000000e0 47 5c 73 71 6c 5c 71 75 65 72 79 3b 3b          # G\sql\query;;

  Version:
    $Id: MSSqlServerInfo.java,v 1.8.2.1 2009-07-30 10:50:05 ickzon Exp $
  Author:
    Matt Brinkley

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `numRetries`
    `private java.lang.String[]` | `serverInfoStrings`
    `private int` | `timeout`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MSSqlServerInfo(java.lang.String host)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `private static java.lang.String` | `extractString(byte[] buf, int len)`
    `int` | `getPortForInstance(java.lang.String instanceName)` Call getInfo() before calling this method.
    `static java.lang.String[]` | `split(java.lang.String s, int ch)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### numRetries

          private final int numRetries

      See Also:
        Constant Field Values

    - #### timeout

          private final int timeout

      See Also:
        Constant Field Values

    - #### serverInfoStrings

          private java.lang.String[] serverInfoStrings

  - ### Constructor Detail

    - #### MSSqlServerInfo

          public MSSqlServerInfo(java.lang.String host)
                          throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

  - ### Method Detail

    - #### getPortForInstance

          public int getPortForInstance(java.lang.String instanceName)
                                 throws java.sql.SQLException

      Call getInfo() before calling this method. It parses the info string returned from SQL Server and looks for the port for the given named instance. If it can't be found, or if getInfo() hadsn't been called, it returns -1.
      Parameters:
        `instanceName` -
      Returns:
        port the given instance is listening on, or -1 if it can't be found.
      Throws:
        `java.sql.SQLException`

    - #### extractString

          private static final java.lang.String extractString(byte[] buf,
                                       int len)

    - #### split

          public static java.lang.String[] split(java.lang.String s,
                                 int ch)

Generated on June 8 2013