net.sourceforge.jtds.jdbc

Class SQLDiagnostic


(package private) class SQLDiagnostic
extends java.lang.Object

Helper class for handling SQL warnings and errors.

Assigns SQL state values in accordance to the native error number returned by the database server.

Version:
$Id: SQLDiagnostic.java,v 1.12 2007/08/05 20:17:54 bheineman Exp $
Authors:
Alin Sinpalean
Mike Hutchinson

Field Summary

(package private) SQLException
exceptions
private static HashMap
mssqlStates
Map to convert Microsoft SQL server error codes to ANSI SQLSTATE codes.
private int
serverType
SQL Server type.
private static HashMap
sybStates
Map to convert Sybase SQL server error codes to ANSI SQLSTATE codes.
(package private) SQLWarning
warnings

Constructor Summary

SQLDiagnostic(int serverType)
Create an SQL message for a specific server type.

Method Summary

(package private) void
addDiagnostic(int number, int state, int serverity, String message, String server, String procName, int line)
Create a dianostic SQLException or SQLWarning.
(package private) void
addException(SQLException e)
(package private) void
addWarning(SQLWarning w)
(package private) void
checkErrors()
Check the exception chain for errors and throw any found as an SQLException.
(package private) void
clearWarnings()
Clear the warning chain.
private static String
getStateCode(int number, int serverType, String defState)
Map an SQL Server error code to an ANSI SQLSTATE code.
(package private) SQLWarning
getWarnings()
Return the warning chain.

Field Details

exceptions

(package private)  SQLException exceptions

mssqlStates

private static final HashMap mssqlStates
Map to convert Microsoft SQL server error codes to ANSI SQLSTATE codes. The values in this table are derived from the list compiled by the FreeTDS project. Thank you for the hard work.

serverType

private final int serverType
SQL Server type. Either Driver.SQLSERVER or Driver.SYBASE.

sybStates

private static final HashMap sybStates
Map to convert Sybase SQL server error codes to ANSI SQLSTATE codes. The values in this table are derived from the list compiled by the FreeTDS project. Thank you for the hard work.

warnings

(package private)  SQLWarning warnings

Constructor Details

SQLDiagnostic

(package private)  SQLDiagnostic(int serverType)
Create an SQL message for a specific server type.
Parameters:
serverType - either Driver.SQLSERVER or Driver.SYBASE

Method Details

addDiagnostic

(package private)  void addDiagnostic(int number,
                                      int state,
                                      int serverity,
                                      String message,
                                      String server,
                                      String procName,
                                      int line)
Create a dianostic SQLException or SQLWarning.
Parameters:
number - SQL Server error number.
state - SQL Server state code.
serverity - SQL Server serverity > 10 = error.
message - SQL Server error message text.
server - SQL Server name.
procName - SQL Server stored procedure name.
line - SQL Server error line number in SQL source.

addException

(package private)  void addException(SQLException e)

addWarning

(package private)  void addWarning(SQLWarning w)

checkErrors

(package private)  void checkErrors()
            throws SQLException
Check the exception chain for errors and throw any found as an SQLException.

clearWarnings

(package private)  void clearWarnings()
Clear the warning chain.

getStateCode

private static String getStateCode(int number,
                                   int serverType,
                                   String defState)
Map an SQL Server error code to an ANSI SQLSTATE code.
Parameters:
number - the SQL Server error number
serverType - Driver.SQLSERVER or Driver.SYBASE
defState - the default state code to return if the mapping fails
Returns:
the SQLSTATE code as a String

getWarnings

(package private)  SQLWarning getWarnings()
Return the warning chain.
Returns:
The warning chain head as a SQLWarning.

Generated on September 18 2009