?? sqlerror.java
字號:
/* Copyright (C) 2002-2007 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file EXCEPTIONS-CONNECTOR-J in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package com.mysql.jdbc;import java.lang.reflect.Constructor;import java.lang.reflect.Method;import java.net.BindException;import java.sql.DataTruncation;import java.sql.SQLException;import java.sql.SQLWarning;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;import java.util.Map;import java.util.TreeMap;import com.mysql.jdbc.exceptions.MySQLDataException;import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException;import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException;import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException;import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException;import com.mysql.jdbc.exceptions.MySQLTransientConnectionException;/** * SQLError is a utility class that maps MySQL error codes to X/Open error codes * as is required by the JDBC spec. * * @author Mark Matthews <mmatthew_at_worldserver.com> * @version $Id: SQLError.java 5122 2006-04-03 15:37:11 +0000 (Mon, 03 Apr 2006) * mmatthews $ */public class SQLError { static final int ER_WARNING_NOT_COMPLETE_ROLLBACK = 1196; private static Map mysqlToSql99State; private static Map mysqlToSqlState; public static final String SQL_STATE_BASE_TABLE_NOT_FOUND = "S0002"; //$NON-NLS-1$ public static final String SQL_STATE_BASE_TABLE_OR_VIEW_ALREADY_EXISTS = "S0001"; //$NON-NLS-1$ public static final String SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND = "42S02"; //$NON-NLS-1$ public static final String SQL_STATE_COLUMN_ALREADY_EXISTS = "S0021"; //$NON-NLS-1$ public static final String SQL_STATE_COLUMN_NOT_FOUND = "S0022"; //$NON-NLS-1$ public static final String SQL_STATE_COMMUNICATION_LINK_FAILURE = "08S01"; //$NON-NLS-1$ public static final String SQL_STATE_CONNECTION_FAIL_DURING_TX = "08007"; //$NON-NLS-1$ public static final String SQL_STATE_CONNECTION_IN_USE = "08002"; //$NON-NLS-1$ public static final String SQL_STATE_CONNECTION_NOT_OPEN = "08003"; //$NON-NLS-1$ public static final String SQL_STATE_CONNECTION_REJECTED = "08004"; //$NON-NLS-1$ public static final String SQL_STATE_DATE_TRUNCATED = "01004"; //$NON-NLS-1$ public static final String SQL_STATE_DATETIME_FIELD_OVERFLOW = "22008"; //$NON-NLS-1$ public static final String SQL_STATE_DEADLOCK = "41000"; //$NON-NLS-1$ public static final String SQL_STATE_DISCONNECT_ERROR = "01002"; //$NON-NLS-1$ public static final String SQL_STATE_DIVISION_BY_ZERO = "22012"; //$NON-NLS-1$ public static final String SQL_STATE_DRIVER_NOT_CAPABLE = "S1C00"; //$NON-NLS-1$ public static final String SQL_STATE_ERROR_IN_ROW = "01S01"; //$NON-NLS-1$ public static final String SQL_STATE_GENERAL_ERROR = "S1000"; //$NON-NLS-1$ public static final String SQL_STATE_ILLEGAL_ARGUMENT = "S1009"; //$NON-NLS-1$ public static final String SQL_STATE_INDEX_ALREADY_EXISTS = "S0011"; //$NON-NLS-1$ public static final String SQL_STATE_INDEX_NOT_FOUND = "S0012"; //$NON-NLS-1$ public static final String SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST = "21S01"; //$NON-NLS-1$ public static final String SQL_STATE_INVALID_AUTH_SPEC = "28000"; //$NON-NLS-1$ public static final String SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST = "22018"; // $NON_NLS-1$ public static final String SQL_STATE_INVALID_COLUMN_NUMBER = "S1002"; //$NON-NLS-1$ public static final String SQL_STATE_INVALID_CONNECTION_ATTRIBUTE = "01S00"; //$NON-NLS-1$ public static final String SQL_STATE_MEMORY_ALLOCATION_FAILURE = "S1001"; //$NON-NLS-1$ public static final String SQL_STATE_MORE_THAN_ONE_ROW_UPDATED_OR_DELETED = "01S04"; //$NON-NLS-1$ public static final String SQL_STATE_NO_DEFAULT_FOR_COLUMN = "S0023"; //$NON-NLS-1$ public static final String SQL_STATE_NO_ROWS_UPDATED_OR_DELETED = "01S03"; //$NON-NLS-1$ public static final String SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE = "22003"; //$NON-NLS-1$ public static final String SQL_STATE_PRIVILEGE_NOT_REVOKED = "01006"; //$NON-NLS-1$ public static final String SQL_STATE_SYNTAX_ERROR = "42000"; //$NON-NLS-1$ public static final String SQL_STATE_TIMEOUT_EXPIRED = "S1T00"; //$NON-NLS-1$ public static final String SQL_STATE_TRANSACTION_RESOLUTION_UNKNOWN = "08007"; // $NON_NLS-1$ public static final String SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE = "08001"; //$NON-NLS-1$ public static final String SQL_STATE_WRONG_NO_OF_PARAMETERS = "07001"; //$NON-NLS-1$ public static final String SQL_STATE_INVALID_TRANSACTION_TERMINATION = "2D000"; // $NON_NLS-1$ private static Map sqlStateMessages; private static final long DEFAULT_WAIT_TIMEOUT_SECONDS = 28800; private static final int DUE_TO_TIMEOUT_FALSE = 0; private static final int DUE_TO_TIMEOUT_MAYBE = 2; private static final int DUE_TO_TIMEOUT_TRUE = 1; private static final Constructor JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR; private static Method THROWABLE_INIT_CAUSE_METHOD; static { if (Util.isJdbc4()) { try { JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR = Class.forName( "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException") .getConstructor( new Class[] { ConnectionImpl.class, Long.TYPE, Exception.class }); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } else { JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR = null; } try { THROWABLE_INIT_CAUSE_METHOD = Throwable.class.getMethod("initCause", new Class[] {Throwable.class}); } catch (Throwable t) { // we're not on a VM that has it THROWABLE_INIT_CAUSE_METHOD = null; } sqlStateMessages = new HashMap(); sqlStateMessages.put(SQL_STATE_DISCONNECT_ERROR, Messages .getString("SQLError.35")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_DATE_TRUNCATED, Messages .getString("SQLError.36")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_PRIVILEGE_NOT_REVOKED, Messages .getString("SQLError.37")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, Messages .getString("SQLError.38")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_ERROR_IN_ROW, Messages .getString("SQLError.39")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_NO_ROWS_UPDATED_OR_DELETED, Messages .getString("SQLError.40")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_MORE_THAN_ONE_ROW_UPDATED_OR_DELETED, Messages.getString("SQLError.41")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_WRONG_NO_OF_PARAMETERS, Messages .getString("SQLError.42")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE, Messages.getString("SQLError.43")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_CONNECTION_IN_USE, Messages .getString("SQLError.44")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_CONNECTION_NOT_OPEN, Messages .getString("SQLError.45")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_CONNECTION_REJECTED, Messages .getString("SQLError.46")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_CONNECTION_FAIL_DURING_TX, Messages .getString("SQLError.47")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_COMMUNICATION_LINK_FAILURE, Messages .getString("SQLError.48")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST, Messages.getString("SQLError.49")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE, Messages .getString("SQLError.50")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_DATETIME_FIELD_OVERFLOW, Messages .getString("SQLError.51")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_DIVISION_BY_ZERO, Messages .getString("SQLError.52")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_DEADLOCK, Messages .getString("SQLError.53")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_INVALID_AUTH_SPEC, Messages .getString("SQLError.54")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_SYNTAX_ERROR, Messages .getString("SQLError.55")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND, Messages .getString("SQLError.56")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_BASE_TABLE_OR_VIEW_ALREADY_EXISTS, Messages.getString("SQLError.57")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_BASE_TABLE_NOT_FOUND, Messages .getString("SQLError.58")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_INDEX_ALREADY_EXISTS, Messages .getString("SQLError.59")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_INDEX_NOT_FOUND, Messages .getString("SQLError.60")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_COLUMN_ALREADY_EXISTS, Messages .getString("SQLError.61")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_COLUMN_NOT_FOUND, Messages .getString("SQLError.62")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_NO_DEFAULT_FOR_COLUMN, Messages .getString("SQLError.63")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_GENERAL_ERROR, Messages .getString("SQLError.64")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_MEMORY_ALLOCATION_FAILURE, Messages .getString("SQLError.65")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_INVALID_COLUMN_NUMBER, Messages .getString("SQLError.66")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_ILLEGAL_ARGUMENT, Messages .getString("SQLError.67")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_DRIVER_NOT_CAPABLE, Messages .getString("SQLError.68")); //$NON-NLS-1$ sqlStateMessages.put(SQL_STATE_TIMEOUT_EXPIRED, Messages .getString("SQLError.69")); //$NON-NLS-1$ mysqlToSqlState = new Hashtable(); // // Communications Errors // // ER_CON_COUNT_ERROR 1040 // ER_BAD_HOST_ERROR 1042 // ER_HANDSHAKE_ERROR 1043 // ER_UNKNOWN_COM_ERROR 1047 // ER_IPSOCK_ERROR 1081 // mysqlToSqlState.put(Constants.integerValueOf(1040), SQL_STATE_CONNECTION_REJECTED); mysqlToSqlState.put(Constants.integerValueOf(1042), SQL_STATE_CONNECTION_REJECTED); mysqlToSqlState.put(Constants.integerValueOf(1043), SQL_STATE_CONNECTION_REJECTED); mysqlToSqlState.put(Constants.integerValueOf(1047), SQL_STATE_COMMUNICATION_LINK_FAILURE); mysqlToSqlState.put(Constants.integerValueOf(1081), SQL_STATE_COMMUNICATION_LINK_FAILURE); // ER_HOST_IS_BLOCKED 1129 // ER_HOST_NOT_PRIVILEGED 1130 mysqlToSqlState.put(Constants.integerValueOf(1129), SQL_STATE_CONNECTION_REJECTED); mysqlToSqlState.put(Constants.integerValueOf(1130), SQL_STATE_CONNECTION_REJECTED); // // Authentication Errors // // ER_ACCESS_DENIED_ERROR 1045 // mysqlToSqlState.put(Constants.integerValueOf(1045), SQL_STATE_INVALID_AUTH_SPEC); // // Resource errors // // ER_CANT_CREATE_FILE 1004 // ER_CANT_CREATE_TABLE 1005 // ER_CANT_LOCK 1015 // ER_DISK_FULL 1021 // ER_CON_COUNT_ERROR 1040 // ER_OUT_OF_RESOURCES 1041 // // Out-of-memory errors // // ER_OUTOFMEMORY 1037 // ER_OUT_OF_SORTMEMORY 1038 // mysqlToSqlState.put(Constants.integerValueOf(1037), SQL_STATE_MEMORY_ALLOCATION_FAILURE); mysqlToSqlState.put(Constants.integerValueOf(1038), SQL_STATE_MEMORY_ALLOCATION_FAILURE); // // Syntax Errors // // ER_PARSE_ERROR 1064 // ER_EMPTY_QUERY 1065 // mysqlToSqlState.put(Constants.integerValueOf(1064), SQL_STATE_SYNTAX_ERROR); mysqlToSqlState.put(Constants.integerValueOf(1065), SQL_STATE_SYNTAX_ERROR); // // Invalid argument errors // // ER_WRONG_FIELD_WITH_GROUP 1055 // ER_WRONG_GROUP_FIELD 1056 // ER_WRONG_SUM_SELECT 1057 // ER_TOO_LONG_IDENT 1059 // ER_DUP_FIELDNAME 1060
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -