Package com.microsoft.sqlserver.jdbc

## Class SQLServerException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.sql.SQLException
      - - com.microsoft.sqlserver.jdbc.SQLServerException

All Implemented Interfaces:
  `Serializable`, `Iterable<Throwable>`

    public final class SQLServerException
    extends SQLException

Represents the exception thrown from any point in the driver that throws a java.sql.SQLException. SQLServerException handles both SQL 92 and XOPEN state codes. They are switchable via a user specified connection property. SQLServerExceptions are written to any open log files the user has specified.

See Also:
  Serialized Form

### Constructor Summary

Constructors
`SQLServerException​(SQLServerError sqlServerError)` Constructs a new SQLServerException from SQL Server error

### Method Summary

All Methods Instance Methods Concrete Methods
`SQLException` `getNextException()` Returns the next SQLException in the chain.
`SQLServerError` `getSQLServerError()` Returns SQLServerError object containing detailed info about exception as received from SQL Server.

### Methods inherited from class java.sql.SQLException

`getErrorCode, getSQLState, iterator, setNextException`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

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

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

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Constructor Detail

#### SQLServerException

    public SQLServerException​(SQLServerError sqlServerError)

Constructs a new SQLServerException from SQL Server error

Parameters:
  `sqlServerError` - SQL Server error

### Method Detail

#### getNextException

    public SQLException getNextException()

Returns the next SQLException in the chain. This implementation supports lazy fetching of additional exceptions from nested stored procedures (issue #2115).

Overrides:
  `getNextException` in class `SQLException`
Returns:
  the next SQLException in the chain, or null if none exists

#### getSQLServerError

    public SQLServerError getSQLServerError()

Returns SQLServerError object containing detailed info about exception as received from SQL Server. This API returns null if no server error has occurred.

Returns:
  SQLServerError