Package net.sourceforge.jtds.jdbc
Class SQLDiagnostic
- java.lang.Object
-
- net.sourceforge.jtds.jdbc.SQLDiagnostic
-
class SQLDiagnostic extends java.lang.ObjectHelper 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 $
- Author:
- Alin Sinpalean, Mike Hutchinson
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.sql.SQLExceptionexceptions(package private) java.sql.SQLExceptionlastException(package private) java.sql.SQLWarninglastWarningprivate static java.util.HashMapmssqlStatesMap to convert Microsoft SQL server error codes to ANSI SQLSTATE codes.private intserverTypeSQL Server type.private static java.util.HashMapsybStatesMap to convert Sybase SQL server error codes to ANSI SQLSTATE codes.(package private) java.sql.SQLWarningwarnings
-
Constructor Summary
Constructors Constructor Description SQLDiagnostic(int serverType)Create an SQL message for a specific server type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddDiagnostic(int number, int state, int serverity, java.lang.String message, java.lang.String server, java.lang.String procName, int line)Create a dianostic SQLException or SQLWarning.(package private) voidaddException(java.sql.SQLException e)(package private) voidaddWarning(java.sql.SQLWarning w)(package private) voidcheckErrors()Check the exception chain for errors and throw any found as an SQLException.(package private) voidclearWarnings()Clear the warning chain.private static java.lang.StringgetStateCode(int number, int serverType, java.lang.String defState)Map an SQL Server error code to an ANSI SQLSTATE code.(package private) java.sql.SQLWarninggetWarnings()Return the warning chain.
-
-
-
Field Detail
-
mssqlStates
private static final java.util.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.
-
sybStates
private static final java.util.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.
-
serverType
private final int serverType
SQL Server type. EitherDriver.SQLSERVERorDriver.SYBASE.
-
exceptions
java.sql.SQLException exceptions
-
lastException
java.sql.SQLException lastException
-
warnings
java.sql.SQLWarning warnings
-
lastWarning
java.sql.SQLWarning lastWarning
-
-
Method Detail
-
addWarning
void addWarning(java.sql.SQLWarning w)
-
addException
void addException(java.sql.SQLException e)
-
addDiagnostic
void addDiagnostic(int number, int state, int serverity, java.lang.String message, java.lang.String server, java.lang.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.
-
clearWarnings
void clearWarnings()
Clear the warning chain.
-
checkErrors
void checkErrors() throws java.sql.SQLExceptionCheck the exception chain for errors and throw any found as an SQLException.- Throws:
java.sql.SQLException
-
getWarnings
java.sql.SQLWarning getWarnings()
Return the warning chain.- Returns:
- The warning chain head as a
SQLWarning.
-
getStateCode
private static java.lang.String getStateCode(int number, int serverType, java.lang.String defState)Map an SQL Server error code to an ANSI SQLSTATE code.- Parameters:
number- the SQL Server error numberserverType-Driver.SQLSERVERorDriver.SYBASEdefState- the default state code to return if the mapping fails- Returns:
- the SQLSTATE code as a
String
-
-