Module com.microsoft.sqlserver.jdbc
Package com.microsoft.sqlserver.jdbc

## Class SQLServerError

- java.lang.Object
- - com.microsoft.sqlserver.jdbc.SQLServerError

All Implemented Interfaces:
  `ISQLServerMessage`, `Serializable`

    public final class SQLServerError
    extends Object
    implements Serializable, ISQLServerMessage

SQLServerError represents a TDS error or message event.

See Also:
  Serialized Form

### Method Summary

All Methods Instance Methods Concrete Methods
`String` `getErrorMessage()` Returns error message as received from SQL Server
`int` `getErrorNumber()` Returns error number as received from SQL Server
`int` `getErrorSeverity()` Returns Severity of error (as int value) as received from SQL Server
`int` `getErrorState()` Returns error state as received from SQL Server
`long` `getLineNumber()` Returns line number where the error occurred in Stored Procedure returned by `getProcedureName()` as received from SQL Server
`String` `getProcedureName()` Returns name of the stored procedure where exception occurs as received from SQL Server
`String` `getServerName()` Returns name of the server where exception occurs as received from SQL Server
`SQLServerError` `getSQLServerMessage()` Returns SQLServerError containing detailed info about SQL Server Message as received from SQL Server.
`void` `setErrorNumber​(int newErrorNumber)` Set a new ErrorNumber for this Message
`void` `setErrorSeverity​(int newSeverity)` Set a new ErrorSeverity for this Message
`SQLException` `toSqlExceptionOrSqlWarning()` Creates a SQLServerException or SQLServerWarning from this SQLServerMessage
`ISQLServerMessage` `toSQLServerInfoMessage()` Downgrade a Error message into a Info message
`ISQLServerMessage` `toSQLServerInfoMessage​(int newErrorSeverity)` Downgrade a Error message into a Info message
`ISQLServerMessage` `toSQLServerInfoMessage​(int newErrorSeverity, int newErrorNumber)` Downgrade a Error message into a Info message

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

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

### Methods inherited from interface com.microsoft.sqlserver.jdbc.ISQLServerMessage

`isErrorMessage, isInfoMessage`

### Method Detail

#### getErrorMessage

    public String getErrorMessage()

Returns error message as received from SQL Server

Specified by:
  `getErrorMessage` in interface `ISQLServerMessage`
Returns:
  Error Message

#### getErrorNumber

    public int getErrorNumber()

Returns error number as received from SQL Server

Specified by:
  `getErrorNumber` in interface `ISQLServerMessage`
Returns:
  Error Number

#### getErrorState

    public int getErrorState()

Returns error state as received from SQL Server

Specified by:
  `getErrorState` in interface `ISQLServerMessage`
Returns:
  Error State

#### getErrorSeverity

    public int getErrorSeverity()

Returns Severity of error (as int value) as received from SQL Server

Specified by:
  `getErrorSeverity` in interface `ISQLServerMessage`
Returns:
  Error Severity

#### getServerName

    public String getServerName()

Returns name of the server where exception occurs as received from SQL Server

Specified by:
  `getServerName` in interface `ISQLServerMessage`
Returns:
  Server Name

#### getProcedureName

    public String getProcedureName()

Returns name of the stored procedure where exception occurs as received from SQL Server

Specified by:
  `getProcedureName` in interface `ISQLServerMessage`
Returns:
  Procedure Name

#### getLineNumber

    public long getLineNumber()

Returns line number where the error occurred in Stored Procedure returned by `getProcedureName()` as received from SQL Server

Specified by:
  `getLineNumber` in interface `ISQLServerMessage`
Returns:
  Line Number

#### getSQLServerMessage

    public SQLServerError getSQLServerMessage()

Description copied from interface: `ISQLServerMessage`
Returns SQLServerError containing detailed info about SQL Server Message as received from SQL Server.

Specified by:
  `getSQLServerMessage` in interface `ISQLServerMessage`
Returns:
  SQLServerError

#### toSQLServerInfoMessage

    public ISQLServerMessage toSQLServerInfoMessage()

Downgrade a Error message into a Info message

This simply create a SQLServerInfoMessage from this SQLServerError, without changing the message content.

Returns:
  ISQLServerMessage

#### toSQLServerInfoMessage

    public ISQLServerMessage toSQLServerInfoMessage​(int newErrorSeverity)

Downgrade a Error message into a Info message

This simply create a SQLServerInfoMessage from this SQLServerError,

Parameters:
  `newErrorSeverity` - - The new ErrorSeverity
Returns:
  ISQLServerMessage

#### toSQLServerInfoMessage

    public ISQLServerMessage toSQLServerInfoMessage​(int newErrorSeverity,
                                                    int newErrorNumber)

Downgrade a Error message into a Info message

This simply create a SQLServerInfoMessage from this SQLServerError,

Parameters:
  `newErrorSeverity` - - If you want to change the ErrorSeverity (-1: leave unchanged)
  `newErrorNumber` - - If you want to change the ErrorNumber (-1: leave unchanged)
Returns:
  ISQLServerMessage

#### setErrorSeverity

    public void setErrorSeverity​(int newSeverity)

Set a new ErrorSeverity for this Message

Parameters:
  `newSeverity` - new severity

#### setErrorNumber

    public void setErrorNumber​(int newErrorNumber)

Set a new ErrorNumber for this Message

Parameters:
  `newErrorNumber` - new error number

#### toSqlExceptionOrSqlWarning

    public SQLException toSqlExceptionOrSqlWarning()

Description copied from interface: `ISQLServerMessage`
Creates a SQLServerException or SQLServerWarning from this SQLServerMessage

Specified by:
  `toSqlExceptionOrSqlWarning` in interface `ISQLServerMessage`
Returns:
  - SQLServerException if it's a SQLServerError object
  - SQLServerWarning if it's a SQLServerInfoMessage object