Member Junction
    Preparing search index...

    Lightweight adapter for testing SQL Server connectivity via raw TCP sockets.

    Does not perform SQL authentication or execute queries — only verifies that the host:port is accepting TCP connections. This is sufficient for preflight checks and post-provisioning validation.

    const adapter = new SqlServerAdapter();
    const result = await adapter.CheckConnectivity('db.example.com', 1433, 10000);
    console.log(result.Reachable ? 'OK' : result.ErrorMessage);
    Index

    Constructors

    Methods

    • Test TCP connectivity to a SQL Server instance.

      Opens a raw TCP socket to the specified host and port. If the connection is established within the timeout, returns { Reachable: true }. Otherwise returns a structured error with a human-readable message tailored to common failure modes (ECONNREFUSED, ENOTFOUND, ETIMEDOUT, ECONNRESET).

      Parameters

      • host: string

        SQL Server hostname or IP address.

      • port: number

        SQL Server TCP port (typically 1433).

      • timeoutMs: number = 5000

        Maximum time to wait for the connection, in milliseconds (default: 5000).

      Returns Promise<SqlConnectivityResult>

      Connectivity result with reachability status, optional error, and latency.

      const result = await adapter.CheckConnectivity('localhost', 1433);
      if (!result.Reachable) {
      console.error(`SQL Server unreachable: ${result.ErrorMessage}`);
      }
    • Run SQL batches in order on one connection, so USE in one batch carries into the next, exactly as SSMS or sqlcmd would run a script split on GO.

      Parameters

      • target: SqlLoginTarget

        Server and credentials; Database is where the session starts.

      • batches: string[]

        Batch texts with the GO separators already removed.

      • onMessage: (message: string) => void

        Receives each PRINT / informational message the server sends.

      Returns Promise<void>

      For the first batch that fails; later batches do not run.

    • Sign in to SQL Server and open target.Database, then disconnect.

      Parameters

      • target: SqlLoginTarget

        Server, database, and credentials to try.

      Returns Promise<SqlLoginResult>

      Whether the sign-in worked and, if not, whether SQL Server refused it.