Class SQLError
java.lang.Object
com.mysql.jdbc.SQLError
SQLError is a utility class that maps MySQL error codes to X/Open error codes as is required by the JDBC spec.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static SQLWarningconvertShowWarningsToSQLWarnings(Connection connection) Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.(package private) static SQLWarningconvertShowWarningsToSQLWarnings(Connection connection, int warningCountIfKnown, boolean forTruncationOnly) Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.static SQLExceptioncreateBatchUpdateException(SQLException underlyingEx, long[] updateCounts, ExceptionInterceptor interceptor) Create a BatchUpdateException taking in consideration the JDBC version in use.static SQLExceptioncreateCommunicationsException(MySQLConnection conn, long lastPacketSentTimeMs, long lastPacketReceivedTimeMs, Exception underlyingException, ExceptionInterceptor interceptor) static StringcreateLinkFailureMessageBasedOnHeuristics(MySQLConnection conn, long lastPacketSentTimeMs, long lastPacketReceivedTimeMs, Exception underlyingException) Creates a communications link failure message to be used in CommunicationsException that (hopefully) has some better information and suggestions based on heuristics.static SQLExceptioncreateSQLException(String message, ExceptionInterceptor interceptor) static SQLExceptioncreateSQLException(String message, ExceptionInterceptor interceptor, Connection conn) static SQLExceptioncreateSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) static SQLExceptioncreateSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor, Connection conn) static SQLExceptioncreateSQLException(String message, String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) static SQLExceptioncreateSQLException(String message, String sqlState, ExceptionInterceptor interceptor) static SQLExceptioncreateSQLException(String message, String sqlState, Throwable cause, ExceptionInterceptor interceptor) static SQLExceptioncreateSQLException(String message, String sqlState, Throwable cause, ExceptionInterceptor interceptor, Connection conn) static SQLExceptionCreate a SQLFeatureNotSupportedException or a NotImplemented exception according to the JDBC version in use.static SQLExceptioncreateSQLFeatureNotSupportedException(String message, String sqlState, ExceptionInterceptor interceptor) Create a SQLFeatureNotSupportedException or a NotImplemented exception according to the JDBC version in use.static void(package private) static String(package private) static StringmysqlToSqlState(int errno, boolean useSql92States) Map MySQL error codes to X/Open or SQL-92 error codes
-
Field Details
-
ER_WARNING_NOT_COMPLETE_ROLLBACK
static final int ER_WARNING_NOT_COMPLETE_ROLLBACK- See Also:
-
SQL_STATE_WARNING
- See Also:
-
SQL_STATE_DISCONNECT_ERROR
- See Also:
-
SQL_STATE_DATA_TRUNCATED
- See Also:
-
SQL_STATE_PRIVILEGE_NOT_REVOKED
- See Also:
-
SQL_STATE_NO_DATA
- See Also:
-
SQL_STATE_WRONG_NO_OF_PARAMETERS
- See Also:
-
SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE
- See Also:
-
SQL_STATE_CONNECTION_IN_USE
- See Also:
-
SQL_STATE_CONNECTION_NOT_OPEN
- See Also:
-
SQL_STATE_CONNECTION_REJECTED
- See Also:
-
SQL_STATE_CONNECTION_FAILURE
- See Also:
-
SQL_STATE_TRANSACTION_RESOLUTION_UNKNOWN
- See Also:
-
SQL_STATE_COMMUNICATION_LINK_FAILURE
- See Also:
-
SQL_STATE_FEATURE_NOT_SUPPORTED
- See Also:
-
SQL_STATE_CARDINALITY_VIOLATION
- See Also:
-
SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST
- See Also:
-
SQL_STATE_STRING_DATA_RIGHT_TRUNCATION
- See Also:
-
SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE
- See Also:
-
SQL_STATE_INVALID_DATETIME_FORMAT
- See Also:
-
SQL_STATE_DATETIME_FIELD_OVERFLOW
- See Also:
-
SQL_STATE_DIVISION_BY_ZERO
- See Also:
-
SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST
- See Also:
-
SQL_STATE_INTEGRITY_CONSTRAINT_VIOLATION
- See Also:
-
SQL_STATE_INVALID_CURSOR_STATE
- See Also:
-
SQL_STATE_INVALID_TRANSACTION_STATE
- See Also:
-
SQL_STATE_INVALID_AUTH_SPEC
- See Also:
-
SQL_STATE_INVALID_TRANSACTION_TERMINATION
- See Also:
-
SQL_STATE_INVALID_CONDITION_NUMBER
- See Also:
-
SQL_STATE_INVALID_CATALOG_NAME
- See Also:
-
SQL_STATE_ROLLBACK_SERIALIZATION_FAILURE
- See Also:
-
SQL_STATE_SYNTAX_ERROR
- See Also:
-
SQL_STATE_ER_TABLE_EXISTS_ERROR
- See Also:
-
SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND
- See Also:
-
SQL_STATE_ER_NO_SUCH_INDEX
- See Also:
-
SQL_STATE_ER_DUP_FIELDNAME
- See Also:
-
SQL_STATE_ER_BAD_FIELD_ERROR
- See Also:
-
SQL_STATE_INVALID_CONNECTION_ATTRIBUTE
- See Also:
-
SQL_STATE_ERROR_IN_ROW
- See Also:
-
SQL_STATE_NO_ROWS_UPDATED_OR_DELETED
- See Also:
-
SQL_STATE_MORE_THAN_ONE_ROW_UPDATED_OR_DELETED
- See Also:
-
SQL_STATE_RESIGNAL_WHEN_HANDLER_NOT_ACTIVE
- See Also:
-
SQL_STATE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER
- See Also:
-
SQL_STATE_CASE_NOT_FOUND_FOR_CASE_STATEMENT
- See Also:
-
SQL_STATE_NULL_VALUE_NOT_ALLOWED
- See Also:
-
SQL_STATE_INVALID_LOGARITHM_ARGUMENT
- See Also:
-
SQL_STATE_ACTIVE_SQL_TRANSACTION
- See Also:
-
SQL_STATE_READ_ONLY_SQL_TRANSACTION
- See Also:
-
SQL_STATE_SRE_PROHIBITED_SQL_STATEMENT_ATTEMPTED
- See Also:
-
SQL_STATE_SRE_FUNCTION_EXECUTED_NO_RETURN_STATEMENT
- See Also:
-
SQL_STATE_ER_QUERY_INTERRUPTED
- See Also:
-
SQL_STATE_BASE_TABLE_OR_VIEW_ALREADY_EXISTS
- See Also:
-
SQL_STATE_BASE_TABLE_NOT_FOUND
- See Also:
-
SQL_STATE_INDEX_ALREADY_EXISTS
- See Also:
-
SQL_STATE_INDEX_NOT_FOUND
- See Also:
-
SQL_STATE_COLUMN_ALREADY_EXISTS
- See Also:
-
SQL_STATE_COLUMN_NOT_FOUND
- See Also:
-
SQL_STATE_NO_DEFAULT_FOR_COLUMN
- See Also:
-
SQL_STATE_GENERAL_ERROR
- See Also:
-
SQL_STATE_MEMORY_ALLOCATION_FAILURE
- See Also:
-
SQL_STATE_INVALID_COLUMN_NUMBER
- See Also:
-
SQL_STATE_ILLEGAL_ARGUMENT
- See Also:
-
SQL_STATE_DRIVER_NOT_CAPABLE
- See Also:
-
SQL_STATE_TIMEOUT_EXPIRED
- See Also:
-
SQL_STATE_CLI_SPECIFIC_CONDITION
- See Also:
-
SQL_STATE_MEMORY_ALLOCATION_ERROR
- See Also:
-
SQL_STATE_XA_RBROLLBACK
- See Also:
-
SQL_STATE_XA_RBDEADLOCK
- See Also:
-
SQL_STATE_XA_RBTIMEOUT
- See Also:
-
SQL_STATE_XA_RMERR
- See Also:
-
SQL_STATE_XAER_NOTA
- See Also:
-
SQL_STATE_XAER_INVAL
- See Also:
-
SQL_STATE_XAER_RMFAIL
- See Also:
-
SQL_STATE_XAER_DUPID
- See Also:
-
SQL_STATE_XAER_OUTSIDE
- See Also:
-
-
Constructor Details
-
SQLError
public SQLError()
-
-
Method Details
-
convertShowWarningsToSQLWarnings
Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances. If 'forTruncationOnly' is true, only looks for truncation warnings, and actually throws DataTruncation as an exception.- Parameters:
connection- the connection to use for getting warnings.- Returns:
- the SQLWarning chain (or null if no warnings)
- Throws:
SQLException- if the warnings could not be retrieved
-
convertShowWarningsToSQLWarnings
static SQLWarning convertShowWarningsToSQLWarnings(Connection connection, int warningCountIfKnown, boolean forTruncationOnly) throws SQLException Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances. If 'forTruncationOnly' is true, only looks for truncation warnings, and actually throws DataTruncation as an exception.- Parameters:
connection- the connection to use for getting warnings.warningCountIfKnown- the warning count (if known), otherwise set it to 0.forTruncationOnly- if this method should only scan for data truncation warnings- Returns:
- the SQLWarning chain (or null if no warnings)
- Throws:
SQLException- if the warnings could not be retrieved, or if data truncation is being scanned for and truncations were found.
-
dumpSqlStatesMappingsAsXml
-
get
-
mysqlToSqlState
Map MySQL error codes to X/Open or SQL-92 error codes- Parameters:
errno- the MySQL error code- Returns:
- the corresponding X/Open or SQL-92 error code
-
createSQLException
public static SQLException createSQLException(String message, String sqlState, ExceptionInterceptor interceptor) -
createSQLException
-
createSQLException
public static SQLException createSQLException(String message, ExceptionInterceptor interceptor, Connection conn) -
createSQLException
public static SQLException createSQLException(String message, String sqlState, Throwable cause, ExceptionInterceptor interceptor) -
createSQLException
public static SQLException createSQLException(String message, String sqlState, Throwable cause, ExceptionInterceptor interceptor, Connection conn) -
createSQLException
public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) -
createSQLException
public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) - Parameters:
message-sqlState-vendorErrorCode-isTransient-interceptor-
-
createSQLException
public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor, Connection conn) -
createCommunicationsException
public static SQLException createCommunicationsException(MySQLConnection conn, long lastPacketSentTimeMs, long lastPacketReceivedTimeMs, Exception underlyingException, ExceptionInterceptor interceptor) -
createLinkFailureMessageBasedOnHeuristics
public static String createLinkFailureMessageBasedOnHeuristics(MySQLConnection conn, long lastPacketSentTimeMs, long lastPacketReceivedTimeMs, Exception underlyingException) Creates a communications link failure message to be used in CommunicationsException that (hopefully) has some better information and suggestions based on heuristics.- Parameters:
conn-lastPacketSentTimeMs-underlyingException-
-
createBatchUpdateException
public static SQLException createBatchUpdateException(SQLException underlyingEx, long[] updateCounts, ExceptionInterceptor interceptor) throws SQLException Create a BatchUpdateException taking in consideration the JDBC version in use. For JDBC version prior to 4.2 the updates count array has int elements while JDBC 4.2 and beyond uses long values.- Parameters:
underlyingEx-updateCounts-interceptor-- Throws:
SQLException
-
createSQLFeatureNotSupportedException
Create a SQLFeatureNotSupportedException or a NotImplemented exception according to the JDBC version in use.- Throws:
SQLException
-
createSQLFeatureNotSupportedException
public static SQLException createSQLFeatureNotSupportedException(String message, String sqlState, ExceptionInterceptor interceptor) throws SQLException Create a SQLFeatureNotSupportedException or a NotImplemented exception according to the JDBC version in use.- Parameters:
message-sqlState-interceptor-- Throws:
SQLException
-