Package net.sourceforge.jtds.jdbc
Class SQLDiagnostic
java.lang.Object
net.sourceforge.jtds.jdbc.SQLDiagnostic
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 $
- Author:
- Alin Sinpalean, Mike Hutchinson
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) SQLException
(package private) SQLException
(package private) SQLWarning
private static final HashMap
Map to convert Microsoft SQL server error codes to ANSI SQLSTATE codes.private final int
SQL Server type.private static final HashMap
Map to convert Sybase SQL server error codes to ANSI SQLSTATE codes.(package private) SQLWarning
-
Constructor Summary
ConstructorsConstructorDescriptionSQLDiagnostic
(int serverType) Create an SQL message for a specific server type. -
Method Summary
Modifier and TypeMethodDescription(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
(package private) void
(package private) void
Check the exception chain for errors and throw any found as an SQLException.(package private) void
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
Return the warning chain.
-
Field Details
-
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
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 serverTypeSQL Server type. EitherDriver.SQLSERVER
orDriver.SYBASE
. -
exceptions
SQLException exceptions -
lastException
SQLException lastException -
warnings
SQLWarning warnings -
lastWarning
SQLWarning lastWarning
-
-
Constructor Details
-
SQLDiagnostic
SQLDiagnostic(int serverType) Create an SQL message for a specific server type.- Parameters:
serverType
- eitherDriver.SQLSERVER
orDriver.SYBASE
-
-
Method Details
-
addWarning
-
addException
-
addDiagnostic
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.
-
clearWarnings
void clearWarnings()Clear the warning chain. -
checkErrors
Check the exception chain for errors and throw any found as an SQLException.- Throws:
SQLException
-
getWarnings
SQLWarning getWarnings()Return the warning chain.- Returns:
- The warning chain head as a
SQLWarning
.
-
getStateCode
Map an SQL Server error code to an ANSI SQLSTATE code.- Parameters:
number
- the SQL Server error numberserverType
-Driver.SQLSERVER
orDriver.SYBASE
defState
- the default state code to return if the mapping fails- Returns:
- the SQLSTATE code as a
String
-