~ubuntu-branches/ubuntu/oneiric/mysql-connector-java/oneiric

« back to all changes in this revision

Viewing changes to src/com/mysql/jdbc/SQLError.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2007-11-30 10:34:13 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20071130103413-mxm4lpfrr4fnjbuj
Tags: 5.1.5+dfsg-1
* New upstream release. Closes: #450718.
* Add Homepage field to debian/control.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 Copyright (C) 2002-2004 MySQL AB
 
2
 Copyright (C) 2002-2007 MySQL AB
3
3
 
4
4
 This program is free software; you can redistribute it and/or modify
5
5
 it under the terms of version 2 of the GNU General Public License as 
24
24
 */
25
25
package com.mysql.jdbc;
26
26
 
 
27
import java.lang.reflect.Constructor;
 
28
import java.lang.reflect.Method;
 
29
import java.net.BindException;
27
30
import java.sql.DataTruncation;
28
31
import java.sql.SQLException;
29
32
import java.sql.SQLWarning;
39
42
import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException;
40
43
import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException;
41
44
import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException;
 
45
import com.mysql.jdbc.exceptions.MySQLTransientConnectionException;
42
46
 
43
47
/**
44
48
 * SQLError is a utility class that maps MySQL error codes to X/Open error codes
45
49
 * as is required by the JDBC spec.
46
50
 * 
47
51
 * @author Mark Matthews <mmatthew_at_worldserver.com>
48
 
 * @version $Id: SQLError.java 5122 2006-04-03 15:37:11Z mmatthews $
 
52
 * @version $Id: SQLError.java 5122 2006-04-03 15:37:11 +0000 (Mon, 03 Apr 2006)
 
53
 *          mmatthews $
49
54
 */
50
55
public class SQLError {
51
56
        static final int ER_WARNING_NOT_COMPLETE_ROLLBACK = 1196;
127
132
        public static final String SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE = "08001"; //$NON-NLS-1$
128
133
 
129
134
        public static final String SQL_STATE_WRONG_NO_OF_PARAMETERS = "07001"; //$NON-NLS-1$
130
 
        
131
 
        public static final String SQL_STATE_INVALID_TRANSACTION_TERMINATION = "2D000"; //$NON_NLS-1$
 
135
 
 
136
        public static final String SQL_STATE_INVALID_TRANSACTION_TERMINATION = "2D000"; // $NON_NLS-1$
132
137
 
133
138
        private static Map sqlStateMessages;
134
139
 
 
140
        private static final long DEFAULT_WAIT_TIMEOUT_SECONDS = 28800;
 
141
 
 
142
        private static final int DUE_TO_TIMEOUT_FALSE = 0;
 
143
 
 
144
        private static final int DUE_TO_TIMEOUT_MAYBE = 2;
 
145
 
 
146
        private static final int DUE_TO_TIMEOUT_TRUE = 1;
 
147
        
 
148
        private static final Constructor JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR;
 
149
        
 
150
        private static Method THROWABLE_INIT_CAUSE_METHOD;
 
151
        
135
152
        static {
 
153
                if (Util.isJdbc4()) {
 
154
                        try {
 
155
                                JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR = Class.forName(
 
156
                                                "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException")
 
157
                                                .getConstructor(
 
158
                                                                new Class[] { ConnectionImpl.class, Long.TYPE, Exception.class });
 
159
                        } catch (SecurityException e) {
 
160
                                throw new RuntimeException(e);
 
161
                        } catch (NoSuchMethodException e) {
 
162
                                throw new RuntimeException(e);
 
163
                        } catch (ClassNotFoundException e) {
 
164
                                throw new RuntimeException(e);
 
165
                        }
 
166
                } else {
 
167
                        JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR = null;
 
168
                }
 
169
                
 
170
                try {
 
171
                        THROWABLE_INIT_CAUSE_METHOD = Throwable.class.getMethod("initCause", new Class[] {Throwable.class});
 
172
                } catch (Throwable t) {
 
173
                        // we're not on a VM that has it
 
174
                        THROWABLE_INIT_CAUSE_METHOD = null;
 
175
                }
 
176
                
136
177
                sqlStateMessages = new HashMap();
137
178
                sqlStateMessages.put(SQL_STATE_DISCONNECT_ERROR, Messages
138
179
                                .getString("SQLError.35")); //$NON-NLS-1$
216
257
                // ER_UNKNOWN_COM_ERROR 1047
217
258
                // ER_IPSOCK_ERROR 1081
218
259
                //
219
 
                mysqlToSqlState.put(new Integer(1040), SQL_STATE_CONNECTION_REJECTED);
220
 
                mysqlToSqlState.put(new Integer(1042), SQL_STATE_CONNECTION_REJECTED);
221
 
                mysqlToSqlState.put(new Integer(1043), SQL_STATE_CONNECTION_REJECTED);
222
 
                mysqlToSqlState.put(new Integer(1047),
 
260
                mysqlToSqlState.put(Constants.integerValueOf(1040), SQL_STATE_CONNECTION_REJECTED);
 
261
                mysqlToSqlState.put(Constants.integerValueOf(1042), SQL_STATE_CONNECTION_REJECTED);
 
262
                mysqlToSqlState.put(Constants.integerValueOf(1043), SQL_STATE_CONNECTION_REJECTED);
 
263
                mysqlToSqlState.put(Constants.integerValueOf(1047),
223
264
                                SQL_STATE_COMMUNICATION_LINK_FAILURE);
224
 
                mysqlToSqlState.put(new Integer(1081),
 
265
                mysqlToSqlState.put(Constants.integerValueOf(1081),
225
266
                                SQL_STATE_COMMUNICATION_LINK_FAILURE);
226
267
 
227
268
                // ER_HOST_IS_BLOCKED 1129
228
269
                // ER_HOST_NOT_PRIVILEGED 1130
229
 
                mysqlToSqlState.put(new Integer(1129), SQL_STATE_CONNECTION_REJECTED);
230
 
                mysqlToSqlState.put(new Integer(1130), SQL_STATE_CONNECTION_REJECTED);
 
270
                mysqlToSqlState.put(Constants.integerValueOf(1129), SQL_STATE_CONNECTION_REJECTED);
 
271
                mysqlToSqlState.put(Constants.integerValueOf(1130), SQL_STATE_CONNECTION_REJECTED);
231
272
 
232
273
                //
233
274
                // Authentication Errors
234
275
                //
235
276
                // ER_ACCESS_DENIED_ERROR 1045
236
277
                //
237
 
                mysqlToSqlState.put(new Integer(1045), SQL_STATE_INVALID_AUTH_SPEC);
 
278
                mysqlToSqlState.put(Constants.integerValueOf(1045), SQL_STATE_INVALID_AUTH_SPEC);
238
279
 
239
280
                //
240
281
                // Resource errors
251
292
                // ER_OUTOFMEMORY 1037
252
293
                // ER_OUT_OF_SORTMEMORY 1038
253
294
                //
254
 
                mysqlToSqlState.put(new Integer(1037),
 
295
                mysqlToSqlState.put(Constants.integerValueOf(1037),
255
296
                                SQL_STATE_MEMORY_ALLOCATION_FAILURE);
256
 
                mysqlToSqlState.put(new Integer(1038),
 
297
                mysqlToSqlState.put(Constants.integerValueOf(1038),
257
298
                                SQL_STATE_MEMORY_ALLOCATION_FAILURE);
258
299
 
259
300
                //
262
303
                // ER_PARSE_ERROR 1064
263
304
                // ER_EMPTY_QUERY 1065
264
305
                //
265
 
                mysqlToSqlState.put(new Integer(1064), SQL_STATE_SYNTAX_ERROR);
266
 
                mysqlToSqlState.put(new Integer(1065), SQL_STATE_SYNTAX_ERROR);
 
306
                mysqlToSqlState.put(Constants.integerValueOf(1064), SQL_STATE_SYNTAX_ERROR);
 
307
                mysqlToSqlState.put(Constants.integerValueOf(1065), SQL_STATE_SYNTAX_ERROR);
267
308
 
268
309
                //
269
310
                // Invalid argument errors
290
331
                // ER_WRONG_FIELD_TERMINATORS 1083
291
332
                // ER_BLOBS_AND_NO_TERMINATED 1084
292
333
                //
293
 
                mysqlToSqlState.put(new Integer(1055), SQL_STATE_ILLEGAL_ARGUMENT);
294
 
                mysqlToSqlState.put(new Integer(1056), SQL_STATE_ILLEGAL_ARGUMENT);
295
 
                mysqlToSqlState.put(new Integer(1057), SQL_STATE_ILLEGAL_ARGUMENT);
296
 
                mysqlToSqlState.put(new Integer(1059), SQL_STATE_ILLEGAL_ARGUMENT);
297
 
                mysqlToSqlState.put(new Integer(1060), SQL_STATE_ILLEGAL_ARGUMENT);
298
 
                mysqlToSqlState.put(new Integer(1061), SQL_STATE_ILLEGAL_ARGUMENT);
299
 
                mysqlToSqlState.put(new Integer(1062), SQL_STATE_ILLEGAL_ARGUMENT);
300
 
                mysqlToSqlState.put(new Integer(1063), SQL_STATE_ILLEGAL_ARGUMENT);
301
 
                mysqlToSqlState.put(new Integer(1066), SQL_STATE_ILLEGAL_ARGUMENT);
302
 
                mysqlToSqlState.put(new Integer(1067), SQL_STATE_ILLEGAL_ARGUMENT);
303
 
                mysqlToSqlState.put(new Integer(1068), SQL_STATE_ILLEGAL_ARGUMENT);
304
 
                mysqlToSqlState.put(new Integer(1069), SQL_STATE_ILLEGAL_ARGUMENT);
305
 
                mysqlToSqlState.put(new Integer(1070), SQL_STATE_ILLEGAL_ARGUMENT);
306
 
                mysqlToSqlState.put(new Integer(1071), SQL_STATE_ILLEGAL_ARGUMENT);
307
 
                mysqlToSqlState.put(new Integer(1072), SQL_STATE_ILLEGAL_ARGUMENT);
308
 
                mysqlToSqlState.put(new Integer(1073), SQL_STATE_ILLEGAL_ARGUMENT);
309
 
                mysqlToSqlState.put(new Integer(1074), SQL_STATE_ILLEGAL_ARGUMENT);
310
 
                mysqlToSqlState.put(new Integer(1075), SQL_STATE_ILLEGAL_ARGUMENT);
311
 
                mysqlToSqlState.put(new Integer(1082), SQL_STATE_ILLEGAL_ARGUMENT);
312
 
                mysqlToSqlState.put(new Integer(1083), SQL_STATE_ILLEGAL_ARGUMENT);
313
 
                mysqlToSqlState.put(new Integer(1084), SQL_STATE_ILLEGAL_ARGUMENT);
 
334
                mysqlToSqlState.put(Constants.integerValueOf(1055), SQL_STATE_ILLEGAL_ARGUMENT);
 
335
                mysqlToSqlState.put(Constants.integerValueOf(1056), SQL_STATE_ILLEGAL_ARGUMENT);
 
336
                mysqlToSqlState.put(Constants.integerValueOf(1057), SQL_STATE_ILLEGAL_ARGUMENT);
 
337
                mysqlToSqlState.put(Constants.integerValueOf(1059), SQL_STATE_ILLEGAL_ARGUMENT);
 
338
                mysqlToSqlState.put(Constants.integerValueOf(1060), SQL_STATE_ILLEGAL_ARGUMENT);
 
339
                mysqlToSqlState.put(Constants.integerValueOf(1061), SQL_STATE_ILLEGAL_ARGUMENT);
 
340
                mysqlToSqlState.put(Constants.integerValueOf(1062), SQL_STATE_ILLEGAL_ARGUMENT);
 
341
                mysqlToSqlState.put(Constants.integerValueOf(1063), SQL_STATE_ILLEGAL_ARGUMENT);
 
342
                mysqlToSqlState.put(Constants.integerValueOf(1066), SQL_STATE_ILLEGAL_ARGUMENT);
 
343
                mysqlToSqlState.put(Constants.integerValueOf(1067), SQL_STATE_ILLEGAL_ARGUMENT);
 
344
                mysqlToSqlState.put(Constants.integerValueOf(1068), SQL_STATE_ILLEGAL_ARGUMENT);
 
345
                mysqlToSqlState.put(Constants.integerValueOf(1069), SQL_STATE_ILLEGAL_ARGUMENT);
 
346
                mysqlToSqlState.put(Constants.integerValueOf(1070), SQL_STATE_ILLEGAL_ARGUMENT);
 
347
                mysqlToSqlState.put(Constants.integerValueOf(1071), SQL_STATE_ILLEGAL_ARGUMENT);
 
348
                mysqlToSqlState.put(Constants.integerValueOf(1072), SQL_STATE_ILLEGAL_ARGUMENT);
 
349
                mysqlToSqlState.put(Constants.integerValueOf(1073), SQL_STATE_ILLEGAL_ARGUMENT);
 
350
                mysqlToSqlState.put(Constants.integerValueOf(1074), SQL_STATE_ILLEGAL_ARGUMENT);
 
351
                mysqlToSqlState.put(Constants.integerValueOf(1075), SQL_STATE_ILLEGAL_ARGUMENT);
 
352
                mysqlToSqlState.put(Constants.integerValueOf(1082), SQL_STATE_ILLEGAL_ARGUMENT);
 
353
                mysqlToSqlState.put(Constants.integerValueOf(1083), SQL_STATE_ILLEGAL_ARGUMENT);
 
354
                mysqlToSqlState.put(Constants.integerValueOf(1084), SQL_STATE_ILLEGAL_ARGUMENT);
314
355
 
315
356
                //
316
357
                // ER_WRONG_VALUE_COUNT 1058
317
358
                //
318
 
                mysqlToSqlState.put(new Integer(1058),
 
359
                mysqlToSqlState.put(Constants.integerValueOf(1058),
319
360
                                SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST);
320
361
 
321
362
                // ER_CANT_CREATE_DB 1006
351
392
                // ER_BAD_DB_ERROR 1049
352
393
                // ER_TABLE_EXISTS_ERROR 1050
353
394
                // ER_BAD_TABLE_ERROR 1051
354
 
                mysqlToSqlState.put(new Integer(1051),
 
395
                mysqlToSqlState.put(Constants.integerValueOf(1051),
355
396
                                SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND);
356
397
 
357
398
                // ER_NON_UNIQ_ERROR 1052
358
399
                // ER_BAD_FIELD_ERROR 1054
359
 
                mysqlToSqlState.put(new Integer(1054), SQL_STATE_COLUMN_NOT_FOUND);
 
400
                mysqlToSqlState.put(Constants.integerValueOf(1054), SQL_STATE_COLUMN_NOT_FOUND);
360
401
 
361
402
                // ER_TEXTFILE_NOT_READABLE 1085
362
403
                // ER_FILE_EXISTS_ERROR 1086
368
409
                // ER_INSERT_INFO 1092
369
410
                // ER_INSERT_TABLE_USED 1093
370
411
                // ER_LOCK_DEADLOCK 1213
371
 
                mysqlToSqlState.put(new Integer(1205), SQL_STATE_DEADLOCK);
372
 
                mysqlToSqlState.put(new Integer(1213), SQL_STATE_DEADLOCK);
 
412
                mysqlToSqlState.put(Constants.integerValueOf(1205), SQL_STATE_DEADLOCK);
 
413
                mysqlToSqlState.put(Constants.integerValueOf(1213), SQL_STATE_DEADLOCK);
373
414
 
374
415
                mysqlToSql99State = new HashMap();
375
416
 
376
 
                mysqlToSql99State.put(new Integer(1205), SQL_STATE_DEADLOCK);
377
 
                mysqlToSql99State.put(new Integer(1213), SQL_STATE_DEADLOCK);
378
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_DUP_KEY),
 
417
                mysqlToSql99State.put(Constants.integerValueOf(1205), SQL_STATE_DEADLOCK);
 
418
                mysqlToSql99State.put(Constants.integerValueOf(1213), SQL_STATE_DEADLOCK);
 
419
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_KEY),
379
420
                                "23000");
380
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_OUTOFMEMORY),
 
421
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_OUTOFMEMORY),
381
422
                                "HY001");
382
 
                mysqlToSql99State.put(new Integer(
 
423
                mysqlToSql99State.put(Constants.integerValueOf(
383
424
                                MysqlErrorNumbers.ER_OUT_OF_SORTMEMORY), "HY001");
384
425
                mysqlToSql99State.put(
385
 
                                new Integer(MysqlErrorNumbers.ER_CON_COUNT_ERROR), "08004");
386
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_BAD_HOST_ERROR),
 
426
                                Constants.integerValueOf(MysqlErrorNumbers.ER_CON_COUNT_ERROR), "08004");
 
427
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_BAD_HOST_ERROR),
387
428
                                "08S01");
388
429
                mysqlToSql99State.put(
389
 
                                new Integer(MysqlErrorNumbers.ER_HANDSHAKE_ERROR), "08S01");
390
 
                mysqlToSql99State.put(new Integer(
 
430
                                Constants.integerValueOf(MysqlErrorNumbers.ER_HANDSHAKE_ERROR), "08S01");
 
431
                mysqlToSql99State.put(Constants.integerValueOf(
391
432
                                MysqlErrorNumbers.ER_DBACCESS_DENIED_ERROR), "42000");
392
 
                mysqlToSql99State.put(new Integer(
 
433
                mysqlToSql99State.put(Constants.integerValueOf(
393
434
                                MysqlErrorNumbers.ER_ACCESS_DENIED_ERROR), "28000");
394
 
                mysqlToSql99State.put(new Integer(
 
435
                mysqlToSql99State.put(Constants.integerValueOf(
395
436
                                MysqlErrorNumbers.ER_TABLE_EXISTS_ERROR), "42S01");
396
437
                mysqlToSql99State.put(
397
 
                                new Integer(MysqlErrorNumbers.ER_BAD_TABLE_ERROR), "42S02");
398
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_NON_UNIQ_ERROR),
 
438
                                Constants.integerValueOf(MysqlErrorNumbers.ER_BAD_TABLE_ERROR), "42S02");
 
439
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NON_UNIQ_ERROR),
399
440
                                "23000");
400
441
                mysqlToSql99State.put(
401
 
                                new Integer(MysqlErrorNumbers.ER_SERVER_SHUTDOWN), "08S01");
 
442
                                Constants.integerValueOf(MysqlErrorNumbers.ER_SERVER_SHUTDOWN), "08S01");
402
443
                mysqlToSql99State.put(
403
 
                                new Integer(MysqlErrorNumbers.ER_BAD_FIELD_ERROR), "42S22");
404
 
                mysqlToSql99State.put(new Integer(
 
444
                                Constants.integerValueOf(MysqlErrorNumbers.ER_BAD_FIELD_ERROR), "42S22");
 
445
                mysqlToSql99State.put(Constants.integerValueOf(
405
446
                                MysqlErrorNumbers.ER_WRONG_FIELD_WITH_GROUP), "42000");
406
 
                mysqlToSql99State.put(new Integer(
 
447
                mysqlToSql99State.put(Constants.integerValueOf(
407
448
                                MysqlErrorNumbers.ER_WRONG_GROUP_FIELD), "42000");
408
449
                mysqlToSql99State.put(
409
 
                                new Integer(MysqlErrorNumbers.ER_WRONG_SUM_SELECT), "42000");
410
 
                mysqlToSql99State.put(new Integer(
 
450
                                Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_SUM_SELECT), "42000");
 
451
                mysqlToSql99State.put(Constants.integerValueOf(
411
452
                                MysqlErrorNumbers.ER_WRONG_VALUE_COUNT), "21S01");
412
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_TOO_LONG_IDENT),
 
453
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_LONG_IDENT),
413
454
                                "42000");
414
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_DUP_FIELDNAME),
 
455
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_FIELDNAME),
415
456
                                "42S21");
416
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_DUP_KEYNAME),
 
457
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_KEYNAME),
417
458
                                "42000");
418
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_DUP_ENTRY),
 
459
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_ENTRY),
419
460
                                "23000");
420
461
                mysqlToSql99State.put(
421
 
                                new Integer(MysqlErrorNumbers.ER_WRONG_FIELD_SPEC), "42000");
422
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_PARSE_ERROR),
423
 
                                "42000");
424
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_EMPTY_QUERY),
425
 
                                "42000");
426
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_NONUNIQ_TABLE),
427
 
                                "42000");
428
 
                mysqlToSql99State.put(
429
 
                                new Integer(MysqlErrorNumbers.ER_INVALID_DEFAULT), "42000");
430
 
                mysqlToSql99State.put(
431
 
                                new Integer(MysqlErrorNumbers.ER_MULTIPLE_PRI_KEY), "42000");
432
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_TOO_MANY_KEYS),
433
 
                                "42000");
434
 
                mysqlToSql99State.put(new Integer(
 
462
                                Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_FIELD_SPEC), "42000");
 
463
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_PARSE_ERROR),
 
464
                                "42000");
 
465
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_EMPTY_QUERY),
 
466
                                "42000");
 
467
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NONUNIQ_TABLE),
 
468
                                "42000");
 
469
                mysqlToSql99State.put(
 
470
                                Constants.integerValueOf(MysqlErrorNumbers.ER_INVALID_DEFAULT), "42000");
 
471
                mysqlToSql99State.put(
 
472
                                Constants.integerValueOf(MysqlErrorNumbers.ER_MULTIPLE_PRI_KEY), "42000");
 
473
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_MANY_KEYS),
 
474
                                "42000");
 
475
                mysqlToSql99State.put(Constants.integerValueOf(
435
476
                                MysqlErrorNumbers.ER_TOO_MANY_KEY_PARTS), "42000");
436
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_TOO_LONG_KEY),
 
477
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_LONG_KEY),
437
478
                                "42000");
438
 
                mysqlToSql99State.put(new Integer(
 
479
                mysqlToSql99State.put(Constants.integerValueOf(
439
480
                                MysqlErrorNumbers.ER_KEY_COLUMN_DOES_NOT_EXITS), "42000");
440
481
                mysqlToSql99State.put(
441
 
                                new Integer(MysqlErrorNumbers.ER_BLOB_USED_AS_KEY), "42000");
442
 
                mysqlToSql99State.put(new Integer(
 
482
                                Constants.integerValueOf(MysqlErrorNumbers.ER_BLOB_USED_AS_KEY), "42000");
 
483
                mysqlToSql99State.put(Constants.integerValueOf(
443
484
                                MysqlErrorNumbers.ER_TOO_BIG_FIELDLENGTH), "42000");
444
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_WRONG_AUTO_KEY),
 
485
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_AUTO_KEY),
445
486
                                "42000");
446
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_FORCING_CLOSE),
447
 
                                "08S01");
448
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_IPSOCK_ERROR),
449
 
                                "08S01");
450
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_NO_SUCH_INDEX),
 
487
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_FORCING_CLOSE),
 
488
                                "08S01");
 
489
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_IPSOCK_ERROR),
 
490
                                "08S01");
 
491
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NO_SUCH_INDEX),
451
492
                                "42S12");
452
 
                mysqlToSql99State.put(new Integer(
 
493
                mysqlToSql99State.put(Constants.integerValueOf(
453
494
                                MysqlErrorNumbers.ER_WRONG_FIELD_TERMINATORS), "42000");
454
 
                mysqlToSql99State.put(new Integer(
 
495
                mysqlToSql99State.put(Constants.integerValueOf(
455
496
                                MysqlErrorNumbers.ER_BLOBS_AND_NO_TERMINATED), "42000");
456
 
                mysqlToSql99State.put(new Integer(
 
497
                mysqlToSql99State.put(Constants.integerValueOf(
457
498
                                MysqlErrorNumbers.ER_CANT_REMOVE_ALL_FIELDS), "42000");
458
 
                mysqlToSql99State.put(new Integer(
 
499
                mysqlToSql99State.put(Constants.integerValueOf(
459
500
                                MysqlErrorNumbers.ER_CANT_DROP_FIELD_OR_KEY), "42000");
460
 
                mysqlToSql99State.put(new Integer(
 
501
                mysqlToSql99State.put(Constants.integerValueOf(
461
502
                                MysqlErrorNumbers.ER_BLOB_CANT_HAVE_DEFAULT), "42000");
462
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_WRONG_DB_NAME),
 
503
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_DB_NAME),
463
504
                                "42000");
464
505
                mysqlToSql99State.put(
465
 
                                new Integer(MysqlErrorNumbers.ER_WRONG_TABLE_NAME), "42000");
466
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_TOO_BIG_SELECT),
 
506
                                Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_TABLE_NAME), "42000");
 
507
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_BIG_SELECT),
467
508
                                "42000");
468
 
                mysqlToSql99State.put(new Integer(
 
509
                mysqlToSql99State.put(Constants.integerValueOf(
469
510
                                MysqlErrorNumbers.ER_UNKNOWN_PROCEDURE), "42000");
470
 
                mysqlToSql99State.put(new Integer(
 
511
                mysqlToSql99State.put(Constants.integerValueOf(
471
512
                                MysqlErrorNumbers.ER_WRONG_PARAMCOUNT_TO_PROCEDURE), "42000");
472
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_UNKNOWN_TABLE),
 
513
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_UNKNOWN_TABLE),
473
514
                                "42S02");
474
 
                mysqlToSql99State.put(new Integer(
 
515
                mysqlToSql99State.put(Constants.integerValueOf(
475
516
                                MysqlErrorNumbers.ER_FIELD_SPECIFIED_TWICE), "42000");
476
 
                mysqlToSql99State.put(new Integer(
 
517
                mysqlToSql99State.put(Constants.integerValueOf(
477
518
                                MysqlErrorNumbers.ER_UNSUPPORTED_EXTENSION), "42000");
478
 
                mysqlToSql99State.put(new Integer(
 
519
                mysqlToSql99State.put(Constants.integerValueOf(
479
520
                                MysqlErrorNumbers.ER_TABLE_MUST_HAVE_COLUMNS), "42000");
480
 
                mysqlToSql99State.put(new Integer(
 
521
                mysqlToSql99State.put(Constants.integerValueOf(
481
522
                                MysqlErrorNumbers.ER_UNKNOWN_CHARACTER_SET), "42000");
482
523
                mysqlToSql99State.put(
483
 
                                new Integer(MysqlErrorNumbers.ER_TOO_BIG_ROWSIZE), "42000");
 
524
                                Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_BIG_ROWSIZE), "42000");
484
525
                mysqlToSql99State.put(
485
 
                                new Integer(MysqlErrorNumbers.ER_WRONG_OUTER_JOIN), "42000");
486
 
                mysqlToSql99State.put(new Integer(
 
526
                                Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_OUTER_JOIN), "42000");
 
527
                mysqlToSql99State.put(Constants.integerValueOf(
487
528
                                MysqlErrorNumbers.ER_NULL_COLUMN_IN_INDEX), "42000");
488
 
                mysqlToSql99State.put(new Integer(
 
529
                mysqlToSql99State.put(Constants.integerValueOf(
489
530
                                MysqlErrorNumbers.ER_PASSWORD_ANONYMOUS_USER), "42000");
490
 
                mysqlToSql99State.put(new Integer(
 
531
                mysqlToSql99State.put(Constants.integerValueOf(
491
532
                                MysqlErrorNumbers.ER_PASSWORD_NOT_ALLOWED), "42000");
492
 
                mysqlToSql99State.put(new Integer(
 
533
                mysqlToSql99State.put(Constants.integerValueOf(
493
534
                                MysqlErrorNumbers.ER_PASSWORD_NO_MATCH), "42000");
494
 
                mysqlToSql99State.put(new Integer(
 
535
                mysqlToSql99State.put(Constants.integerValueOf(
495
536
                                MysqlErrorNumbers.ER_WRONG_VALUE_COUNT_ON_ROW), "21S01");
496
 
                mysqlToSql99State.put(new Integer(
 
537
                mysqlToSql99State.put(Constants.integerValueOf(
497
538
                                MysqlErrorNumbers.ER_INVALID_USE_OF_NULL), "42000");
498
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_REGEXP_ERROR),
 
539
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_REGEXP_ERROR),
499
540
                                "42000");
500
 
                mysqlToSql99State.put(new Integer(
 
541
                mysqlToSql99State.put(Constants.integerValueOf(
501
542
                                MysqlErrorNumbers.ER_MIX_OF_GROUP_FUNC_AND_FIELDS), "42000");
502
 
                mysqlToSql99State.put(new Integer(
 
543
                mysqlToSql99State.put(Constants.integerValueOf(
503
544
                                MysqlErrorNumbers.ER_NONEXISTING_GRANT), "42000");
504
 
                mysqlToSql99State.put(new Integer(
 
545
                mysqlToSql99State.put(Constants.integerValueOf(
505
546
                                MysqlErrorNumbers.ER_TABLEACCESS_DENIED_ERROR), "42000");
506
 
                mysqlToSql99State.put(new Integer(
 
547
                mysqlToSql99State.put(Constants.integerValueOf(
507
548
                                MysqlErrorNumbers.ER_COLUMNACCESS_DENIED_ERROR), "42000");
508
 
                mysqlToSql99State.put(new Integer(
 
549
                mysqlToSql99State.put(Constants.integerValueOf(
509
550
                                MysqlErrorNumbers.ER_ILLEGAL_GRANT_FOR_TABLE), "42000");
510
 
                mysqlToSql99State.put(new Integer(
 
551
                mysqlToSql99State.put(Constants.integerValueOf(
511
552
                                MysqlErrorNumbers.ER_GRANT_WRONG_HOST_OR_USER), "42000");
512
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_NO_SUCH_TABLE),
 
553
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NO_SUCH_TABLE),
513
554
                                "42S02");
514
 
                mysqlToSql99State.put(new Integer(
 
555
                mysqlToSql99State.put(Constants.integerValueOf(
515
556
                                MysqlErrorNumbers.ER_NONEXISTING_TABLE_GRANT), "42000");
516
 
                mysqlToSql99State.put(new Integer(
 
557
                mysqlToSql99State.put(Constants.integerValueOf(
517
558
                                MysqlErrorNumbers.ER_NOT_ALLOWED_COMMAND), "42000");
518
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_SYNTAX_ERROR),
 
559
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_SYNTAX_ERROR),
519
560
                                "42000");
520
 
                mysqlToSql99State.put(new Integer(
 
561
                mysqlToSql99State.put(Constants.integerValueOf(
521
562
                                MysqlErrorNumbers.ER_ABORTING_CONNECTION), "08S01");
522
 
                mysqlToSql99State.put(new Integer(
 
563
                mysqlToSql99State.put(Constants.integerValueOf(
523
564
                                MysqlErrorNumbers.ER_NET_PACKET_TOO_LARGE), "08S01");
524
 
                mysqlToSql99State.put(new Integer(
 
565
                mysqlToSql99State.put(Constants.integerValueOf(
525
566
                                MysqlErrorNumbers.ER_NET_READ_ERROR_FROM_PIPE), "08S01");
526
567
                mysqlToSql99State.put(
527
 
                                new Integer(MysqlErrorNumbers.ER_NET_FCNTL_ERROR), "08S01");
528
 
                mysqlToSql99State.put(new Integer(
 
568
                                Constants.integerValueOf(MysqlErrorNumbers.ER_NET_FCNTL_ERROR), "08S01");
 
569
                mysqlToSql99State.put(Constants.integerValueOf(
529
570
                                MysqlErrorNumbers.ER_NET_PACKETS_OUT_OF_ORDER), "08S01");
530
 
                mysqlToSql99State.put(new Integer(
 
571
                mysqlToSql99State.put(Constants.integerValueOf(
531
572
                                MysqlErrorNumbers.ER_NET_UNCOMPRESS_ERROR), "08S01");
532
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_NET_READ_ERROR),
 
573
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NET_READ_ERROR),
533
574
                                "08S01");
534
 
                mysqlToSql99State.put(new Integer(
 
575
                mysqlToSql99State.put(Constants.integerValueOf(
535
576
                                MysqlErrorNumbers.ER_NET_READ_INTERRUPTED), "08S01");
536
 
                mysqlToSql99State.put(new Integer(
 
577
                mysqlToSql99State.put(Constants.integerValueOf(
537
578
                                MysqlErrorNumbers.ER_NET_ERROR_ON_WRITE), "08S01");
538
 
                mysqlToSql99State.put(new Integer(
 
579
                mysqlToSql99State.put(Constants.integerValueOf(
539
580
                                MysqlErrorNumbers.ER_NET_WRITE_INTERRUPTED), "08S01");
540
581
                mysqlToSql99State.put(
541
 
                                new Integer(MysqlErrorNumbers.ER_TOO_LONG_STRING), "42000");
542
 
                mysqlToSql99State.put(new Integer(
 
582
                                Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_LONG_STRING), "42000");
 
583
                mysqlToSql99State.put(Constants.integerValueOf(
543
584
                                MysqlErrorNumbers.ER_TABLE_CANT_HANDLE_BLOB), "42000");
544
585
                mysqlToSql99State
545
 
                                .put(new Integer(
 
586
                                .put(Constants.integerValueOf(
546
587
                                                MysqlErrorNumbers.ER_TABLE_CANT_HANDLE_AUTO_INCREMENT),
547
588
                                                "42000");
548
 
                mysqlToSql99State.put(new Integer(
 
589
                mysqlToSql99State.put(Constants.integerValueOf(
549
590
                                MysqlErrorNumbers.ER_WRONG_COLUMN_NAME), "42000");
550
591
                mysqlToSql99State.put(
551
 
                                new Integer(MysqlErrorNumbers.ER_WRONG_KEY_COLUMN), "42000");
552
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_DUP_UNIQUE),
 
592
                                Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_KEY_COLUMN), "42000");
 
593
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_UNIQUE),
553
594
                                "23000");
554
 
                mysqlToSql99State.put(new Integer(
 
595
                mysqlToSql99State.put(Constants.integerValueOf(
555
596
                                MysqlErrorNumbers.ER_BLOB_KEY_WITHOUT_LENGTH), "42000");
556
 
                mysqlToSql99State.put(new Integer(
 
597
                mysqlToSql99State.put(Constants.integerValueOf(
557
598
                                MysqlErrorNumbers.ER_PRIMARY_CANT_HAVE_NULL), "42000");
558
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_TOO_MANY_ROWS),
 
599
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_MANY_ROWS),
559
600
                                "42000");
560
 
                mysqlToSql99State.put(new Integer(
 
601
                mysqlToSql99State.put(Constants.integerValueOf(
561
602
                                MysqlErrorNumbers.ER_REQUIRES_PRIMARY_KEY), "42000");
562
 
                mysqlToSql99State.put(new Integer(
 
603
                mysqlToSql99State.put(Constants.integerValueOf(
563
604
                                MysqlErrorNumbers.ER_CHECK_NO_SUCH_TABLE), "42000");
564
 
                mysqlToSql99State.put(new Integer(
 
605
                mysqlToSql99State.put(Constants.integerValueOf(
565
606
                                MysqlErrorNumbers.ER_CHECK_NOT_IMPLEMENTED), "42000");
566
 
                mysqlToSql99State.put(new Integer(
 
607
                mysqlToSql99State.put(Constants.integerValueOf(
567
608
                                MysqlErrorNumbers.ER_CANT_DO_THIS_DURING_AN_TRANSACTION),
568
609
                                "25000");
569
 
                mysqlToSql99State.put(new Integer(
 
610
                mysqlToSql99State.put(Constants.integerValueOf(
570
611
                                MysqlErrorNumbers.ER_NEW_ABORTING_CONNECTION), "08S01");
571
612
                mysqlToSql99State.put(
572
 
                                new Integer(MysqlErrorNumbers.ER_MASTER_NET_READ), "08S01");
 
613
                                Constants.integerValueOf(MysqlErrorNumbers.ER_MASTER_NET_READ), "08S01");
573
614
                mysqlToSql99State.put(
574
 
                                new Integer(MysqlErrorNumbers.ER_MASTER_NET_WRITE), "08S01");
575
 
                mysqlToSql99State.put(new Integer(
 
615
                                Constants.integerValueOf(MysqlErrorNumbers.ER_MASTER_NET_WRITE), "08S01");
 
616
                mysqlToSql99State.put(Constants.integerValueOf(
576
617
                                MysqlErrorNumbers.ER_TOO_MANY_USER_CONNECTIONS), "42000");
577
 
                mysqlToSql99State.put(new Integer(
 
618
                mysqlToSql99State.put(Constants.integerValueOf(
578
619
                                MysqlErrorNumbers.ER_READ_ONLY_TRANSACTION), "25000");
579
 
                mysqlToSql99State.put(new Integer(
 
620
                mysqlToSql99State.put(Constants.integerValueOf(
580
621
                                MysqlErrorNumbers.ER_NO_PERMISSION_TO_CREATE_USER), "42000");
581
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_LOCK_DEADLOCK),
 
622
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_LOCK_DEADLOCK),
582
623
                                "40001");
583
 
                mysqlToSql99State.put(new Integer(
 
624
                mysqlToSql99State.put(Constants.integerValueOf(
584
625
                                MysqlErrorNumbers.ER_NO_REFERENCED_ROW), "23000");
585
 
                mysqlToSql99State.put(new Integer(
 
626
                mysqlToSql99State.put(Constants.integerValueOf(
586
627
                                MysqlErrorNumbers.ER_ROW_IS_REFERENCED), "23000");
587
 
                mysqlToSql99State.put(new Integer(
 
628
                mysqlToSql99State.put(Constants.integerValueOf(
588
629
                                MysqlErrorNumbers.ER_CONNECT_TO_MASTER), "08S01");
589
 
                mysqlToSql99State.put(new Integer(
 
630
                mysqlToSql99State.put(Constants.integerValueOf(
590
631
                                MysqlErrorNumbers.ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),
591
632
                                "21000");
592
 
                mysqlToSql99State.put(new Integer(
 
633
                mysqlToSql99State.put(Constants.integerValueOf(
593
634
                                MysqlErrorNumbers.ER_USER_LIMIT_REACHED), "42000");
594
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_NO_DEFAULT),
 
635
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NO_DEFAULT),
595
636
                                "42000");
596
 
                mysqlToSql99State.put(new Integer(
 
637
                mysqlToSql99State.put(Constants.integerValueOf(
597
638
                                MysqlErrorNumbers.ER_WRONG_VALUE_FOR_VAR), "42000");
598
 
                mysqlToSql99State.put(new Integer(
 
639
                mysqlToSql99State.put(Constants.integerValueOf(
599
640
                                MysqlErrorNumbers.ER_WRONG_TYPE_FOR_VAR), "42000");
600
 
                mysqlToSql99State.put(new Integer(
 
641
                mysqlToSql99State.put(Constants.integerValueOf(
601
642
                                MysqlErrorNumbers.ER_CANT_USE_OPTION_HERE), "42000");
602
 
                mysqlToSql99State.put(new Integer(
 
643
                mysqlToSql99State.put(Constants.integerValueOf(
603
644
                                MysqlErrorNumbers.ER_NOT_SUPPORTED_YET), "42000");
604
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_WRONG_FK_DEF),
 
645
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_FK_DEF),
605
646
                                "42000");
606
647
                mysqlToSql99State.put(
607
 
                                new Integer(MysqlErrorNumbers.ER_OPERAND_COLUMNS), "21000");
608
 
                mysqlToSql99State.put(new Integer(
 
648
                                Constants.integerValueOf(MysqlErrorNumbers.ER_OPERAND_COLUMNS), "21000");
 
649
                mysqlToSql99State.put(Constants.integerValueOf(
609
650
                                MysqlErrorNumbers.ER_SUBQUERY_NO_1_ROW), "21000");
610
 
                mysqlToSql99State.put(new Integer(
 
651
                mysqlToSql99State.put(Constants.integerValueOf(
611
652
                                MysqlErrorNumbers.ER_ILLEGAL_REFERENCE), "42S22");
612
 
                mysqlToSql99State.put(new Integer(
 
653
                mysqlToSql99State.put(Constants.integerValueOf(
613
654
                                MysqlErrorNumbers.ER_DERIVED_MUST_HAVE_ALIAS), "42000");
614
 
                mysqlToSql99State.put(new Integer(MysqlErrorNumbers.ER_SELECT_REDUCED),
 
655
                mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_SELECT_REDUCED),
615
656
                                "01000");
616
 
                mysqlToSql99State.put(new Integer(
 
657
                mysqlToSql99State.put(Constants.integerValueOf(
617
658
                                MysqlErrorNumbers.ER_TABLENAME_NOT_ALLOWED_HERE), "42000");
618
 
                mysqlToSql99State.put(new Integer(
 
659
                mysqlToSql99State.put(Constants.integerValueOf(
619
660
                                MysqlErrorNumbers.ER_NOT_SUPPORTED_AUTH_MODE), "08004");
620
 
                mysqlToSql99State.put(new Integer(
 
661
                mysqlToSql99State.put(Constants.integerValueOf(
621
662
                                MysqlErrorNumbers.ER_SPATIAL_CANT_HAVE_NULL), "42000");
622
 
                mysqlToSql99State.put(new Integer(
 
663
                mysqlToSql99State.put(Constants.integerValueOf(
623
664
                                MysqlErrorNumbers.ER_COLLATION_CHARSET_MISMATCH), "42000");
624
 
                mysqlToSql99State.put(new Integer(
 
665
                mysqlToSql99State.put(Constants.integerValueOf(
625
666
                                MysqlErrorNumbers.ER_WARN_TOO_FEW_RECORDS), "01000");
626
 
                mysqlToSql99State.put(new Integer(
 
667
                mysqlToSql99State.put(Constants.integerValueOf(
627
668
                                MysqlErrorNumbers.ER_WARN_TOO_MANY_RECORDS), "01000");
628
 
                mysqlToSql99State.put(new Integer(
 
669
                mysqlToSql99State.put(Constants.integerValueOf(
629
670
                                MysqlErrorNumbers.ER_WARN_NULL_TO_NOTNULL), "01000");
630
 
                mysqlToSql99State.put(new Integer(
 
671
                mysqlToSql99State.put(Constants.integerValueOf(
631
672
                                MysqlErrorNumbers.ER_WARN_DATA_OUT_OF_RANGE), "01000");
632
 
                mysqlToSql99State.put(new Integer(
 
673
                mysqlToSql99State.put(Constants.integerValueOf(
633
674
                                MysqlErrorNumbers.ER_WARN_DATA_TRUNCATED), "01000");
634
 
                mysqlToSql99State.put(new Integer(
 
675
                mysqlToSql99State.put(Constants.integerValueOf(
635
676
                                MysqlErrorNumbers.ER_WRONG_NAME_FOR_INDEX), "42000");
636
 
                mysqlToSql99State.put(new Integer(
 
677
                mysqlToSql99State.put(Constants.integerValueOf(
637
678
                                MysqlErrorNumbers.ER_WRONG_NAME_FOR_CATALOG), "42000");
638
 
                mysqlToSql99State.put(new Integer(
 
679
                mysqlToSql99State.put(Constants.integerValueOf(
639
680
                                MysqlErrorNumbers.ER_UNKNOWN_STORAGE_ENGINE), "42000");
640
681
        }
641
682
 
835
876
        }
836
877
 
837
878
        private static String mysqlToSql99(int errno) {
838
 
                Integer err = new Integer(errno);
 
879
                Integer err = Constants.integerValueOf(errno);
839
880
 
840
881
                if (mysqlToSql99State.containsKey(err)) {
841
882
                        return (String) mysqlToSql99State.get(err);
861
902
        }
862
903
 
863
904
        private static String mysqlToXOpen(int errno) {
864
 
                Integer err = new Integer(errno);
 
905
                Integer err = Constants.integerValueOf(errno);
865
906
 
866
907
                if (mysqlToSqlState.containsKey(err)) {
867
908
                        return (String) mysqlToSqlState.get(err);
883
924
 
884
925
        public static SQLException createSQLException(String message,
885
926
                        String sqlState) {
886
 
                if (sqlState != null) {
887
 
                        if (sqlState.startsWith("08")) {
888
 
                                return new MySQLNonTransientConnectionException(message,
889
 
                                                sqlState);
890
 
                        }
891
 
 
892
 
                        if (sqlState.startsWith("22")) {
893
 
                                return new MySQLDataException(message, sqlState);
894
 
                        }
895
 
 
896
 
                        if (sqlState.startsWith("23")) {
897
 
                                return new MySQLIntegrityConstraintViolationException(message,
898
 
                                                sqlState);
899
 
                        }
900
 
 
901
 
                        if (sqlState.startsWith("42")) {
902
 
                                return new MySQLSyntaxErrorException(message, sqlState);
903
 
                        }
904
 
 
905
 
                        if (sqlState.startsWith("40")) {
906
 
                                return new MySQLTransactionRollbackException(message, sqlState);
907
 
                        }
908
 
                }
909
 
 
910
 
                return new SQLException(message, sqlState);
 
927
                return createSQLException(message, sqlState, 0);
911
928
        }
912
929
 
913
930
        public static SQLException createSQLException(String message) {
914
931
                return new SQLException(message);
915
932
        }
916
933
 
 
934
        public static SQLException createSQLException(String message, String sqlState, Throwable cause) {
 
935
                if (THROWABLE_INIT_CAUSE_METHOD == null) {
 
936
                        if (cause != null) {
 
937
                                message = message + " due to " + cause.toString();
 
938
                        }
 
939
                }
 
940
                
 
941
                SQLException sqlEx = createSQLException(message, sqlState);
 
942
                
 
943
                if (cause != null && THROWABLE_INIT_CAUSE_METHOD != null) {
 
944
                        try {
 
945
                                THROWABLE_INIT_CAUSE_METHOD.invoke(sqlEx, new Object[] {cause});
 
946
                        } catch (Throwable t) {
 
947
                                // we're not going to muck with that here, since it's
 
948
                                // an error condition anyway!
 
949
                        }
 
950
                }
 
951
                
 
952
                return sqlEx;
 
953
        }
 
954
        
917
955
        public static SQLException createSQLException(String message,
918
956
                        String sqlState, int vendorErrorCode) {
919
 
                if (sqlState != null) {
920
 
                        if (sqlState.startsWith("08")) {
921
 
                                return new MySQLNonTransientConnectionException(message,
922
 
                                                sqlState, vendorErrorCode);
923
 
                        }
924
 
 
925
 
                        if (sqlState.startsWith("22")) {
926
 
                                return new MySQLDataException(message, sqlState,
927
 
                                                vendorErrorCode);
928
 
                        }
929
 
 
930
 
                        if (sqlState.startsWith("23")) {
931
 
                                return new MySQLIntegrityConstraintViolationException(message,
932
 
                                                sqlState, vendorErrorCode);
933
 
                        }
934
 
 
935
 
                        if (sqlState.startsWith("42")) {
936
 
                                return new MySQLSyntaxErrorException(message, sqlState,
937
 
                                                vendorErrorCode);
938
 
                        }
939
 
 
940
 
                        if (sqlState.startsWith("40")) {
941
 
                                return new MySQLTransactionRollbackException(message, sqlState,
942
 
                                                vendorErrorCode);
943
 
                        }
944
 
                }
945
 
 
946
 
                return new SQLException(message, sqlState, vendorErrorCode);
 
957
                return createSQLException(message, sqlState, vendorErrorCode, false);
 
958
        }
 
959
        
 
960
        public static SQLException createSQLException(String message,
 
961
                        String sqlState, int vendorErrorCode, boolean isTransient) {
 
962
                try {
 
963
                        if (sqlState != null) {
 
964
                                if (sqlState.startsWith("08")) {
 
965
                                        if (isTransient) {
 
966
                                                if (!Util.isJdbc4()) {
 
967
                                                        return new MySQLTransientConnectionException(
 
968
                                                                        message, sqlState, vendorErrorCode);
 
969
                                                }
 
970
 
 
971
                                                return (SQLException) Util
 
972
                                                                .getInstance(
 
973
                                                                                "com.mysql.jdbc.exceptions.jdbc4.MySQLTransientConnectionException",
 
974
                                                                                new Class[] { String.class,
 
975
                                                                                                String.class, Integer.TYPE },
 
976
                                                                                new Object[] { message, sqlState,
 
977
                                                                                                Constants.integerValueOf(vendorErrorCode) });
 
978
                                        }
 
979
 
 
980
                                        if (!Util.isJdbc4()) {
 
981
                                                return new MySQLNonTransientConnectionException(
 
982
                                                                message, sqlState, vendorErrorCode);
 
983
                                        }
 
984
 
 
985
                                        return (SQLException) Util
 
986
                                                        .getInstance(
 
987
                                                                        "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException",
 
988
                                                                        new Class[] { String.class, String.class,
 
989
                                                                                        Integer.TYPE  }, new Object[] {
 
990
                                                                                        message, sqlState,
 
991
                                                                                        Constants.integerValueOf(vendorErrorCode) });
 
992
                                }
 
993
 
 
994
                                if (sqlState.startsWith("22")) {
 
995
                                        if (!Util.isJdbc4()) {
 
996
                                                return new MySQLDataException(message, sqlState,
 
997
                                                                vendorErrorCode);
 
998
                                        }
 
999
 
 
1000
                                        return (SQLException) Util
 
1001
                                                        .getInstance(
 
1002
                                                                        "com.mysql.jdbc.exceptions.jdbc4.MySQLDataException",
 
1003
                                                                        new Class[] { String.class, String.class,
 
1004
                                                                                        Integer.TYPE  }, new Object[] {
 
1005
                                                                                        message, sqlState,
 
1006
                                                                                        Constants.integerValueOf(vendorErrorCode) });
 
1007
                                }
 
1008
 
 
1009
                                if (sqlState.startsWith("23")) {
 
1010
 
 
1011
                                        if (!Util.isJdbc4()) {
 
1012
                                                return new MySQLIntegrityConstraintViolationException(
 
1013
                                                                message, sqlState, vendorErrorCode);
 
1014
                                        }
 
1015
 
 
1016
                                        return (SQLException) Util
 
1017
                                                        .getInstance(
 
1018
                                                                        "com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException",
 
1019
                                                                        new Class[] { String.class, String.class,
 
1020
                                                                                        Integer.TYPE  }, new Object[] {
 
1021
                                                                                        message, sqlState,
 
1022
                                                                                        Constants.integerValueOf(vendorErrorCode) });
 
1023
                                }
 
1024
 
 
1025
                                if (sqlState.startsWith("42")) {
 
1026
                                        if (!Util.isJdbc4()) {
 
1027
                                                return new MySQLSyntaxErrorException(message, sqlState,
 
1028
                                                                vendorErrorCode);
 
1029
                                        }
 
1030
 
 
1031
                                        return (SQLException) Util
 
1032
                                                        .getInstance(
 
1033
                                                                        "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException",
 
1034
                                                                        new Class[] { String.class, String.class,
 
1035
                                                                                        Integer.TYPE  }, new Object[] {
 
1036
                                                                                        message, sqlState,
 
1037
                                                                                        Constants.integerValueOf(vendorErrorCode) });
 
1038
                                }
 
1039
 
 
1040
                                if (sqlState.startsWith("40")) {
 
1041
                                        if (!Util.isJdbc4()) {
 
1042
                                                return new MySQLTransactionRollbackException(message,
 
1043
                                                                sqlState, vendorErrorCode);
 
1044
                                        }
 
1045
 
 
1046
                                        return (SQLException) Util
 
1047
                                                        .getInstance(
 
1048
                                                                        "com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException",
 
1049
                                                                        new Class[] { String.class, String.class,
 
1050
                                                                                        Integer.TYPE  }, new Object[] {
 
1051
                                                                                        message, sqlState,
 
1052
                                                                                        Constants.integerValueOf(vendorErrorCode) });
 
1053
                                }
 
1054
                        }
 
1055
 
 
1056
                        return new SQLException(message, sqlState, vendorErrorCode);
 
1057
                } catch (SQLException sqlEx) {
 
1058
                        return new SQLException(
 
1059
                                        "Unable to create correct SQLException class instance, error class/codes may be incorrect. Reason: "
 
1060
                                                        + Util.stackTraceToString(sqlEx),
 
1061
                                        SQL_STATE_GENERAL_ERROR);
 
1062
                }
 
1063
        }
 
1064
        
 
1065
        public static SQLException createCommunicationsException(ConnectionImpl conn, long lastPacketSentTimeMs,
 
1066
                        Exception underlyingException) {
 
1067
                SQLException exToReturn = null;
 
1068
                
 
1069
                if (!Util.isJdbc4()) {
 
1070
                        exToReturn = new CommunicationsException(conn, lastPacketSentTimeMs, underlyingException);
 
1071
                } else {
 
1072
                
 
1073
                        try {
 
1074
                                exToReturn = (SQLException) Util.handleNewInstance(JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR, new Object[] {
 
1075
                                        conn, Constants.longValueOf(lastPacketSentTimeMs), underlyingException});
 
1076
                        } catch (SQLException sqlEx) {
 
1077
                                // We should _never_ get this, but let's not swallow it either
 
1078
                                
 
1079
                                return sqlEx;
 
1080
                        }
 
1081
                }
 
1082
                
 
1083
                if (THROWABLE_INIT_CAUSE_METHOD != null && underlyingException != null) {
 
1084
                        try {
 
1085
                                THROWABLE_INIT_CAUSE_METHOD.invoke(exToReturn, new Object[] {underlyingException});
 
1086
                        } catch (Throwable t) {
 
1087
                                // we're not going to muck with that here, since it's
 
1088
                                // an error condition anyway!
 
1089
                        }
 
1090
                }
 
1091
                
 
1092
                return exToReturn;
 
1093
        }
 
1094
        
 
1095
        /**
 
1096
         * Creates a communications link failure message to be used
 
1097
         * in CommunicationsException that (hopefully) has some better
 
1098
         * information and suggestions based on heuristics.
 
1099
         *  
 
1100
         * @param conn
 
1101
         * @param lastPacketSentTimeMs
 
1102
         * @param underlyingException
 
1103
         * @param streamingResultSetInPlay
 
1104
         * @return
 
1105
         */
 
1106
        public static String createLinkFailureMessageBasedOnHeuristics(
 
1107
                        ConnectionImpl conn,
 
1108
                        long lastPacketSentTimeMs, Exception underlyingException,
 
1109
                        boolean streamingResultSetInPlay) {
 
1110
                long serverTimeoutSeconds = 0;
 
1111
                boolean isInteractiveClient = false;
 
1112
 
 
1113
                if (conn != null) {
 
1114
                        isInteractiveClient = conn.getInteractiveClient();
 
1115
 
 
1116
                        String serverTimeoutSecondsStr = null;
 
1117
 
 
1118
                        if (isInteractiveClient) {
 
1119
                                serverTimeoutSecondsStr = conn
 
1120
                                                .getServerVariable("interactive_timeout"); //$NON-NLS-1$
 
1121
                        } else {
 
1122
                                serverTimeoutSecondsStr = conn
 
1123
                                                .getServerVariable("wait_timeout"); //$NON-NLS-1$
 
1124
                        }
 
1125
 
 
1126
                        if (serverTimeoutSecondsStr != null) {
 
1127
                                try {
 
1128
                                        serverTimeoutSeconds = Long
 
1129
                                                        .parseLong(serverTimeoutSecondsStr);
 
1130
                                } catch (NumberFormatException nfe) {
 
1131
                                        serverTimeoutSeconds = 0;
 
1132
                                }
 
1133
                        }
 
1134
                }
 
1135
 
 
1136
                StringBuffer exceptionMessageBuf = new StringBuffer();
 
1137
 
 
1138
                if (lastPacketSentTimeMs == 0) {
 
1139
                        lastPacketSentTimeMs = System.currentTimeMillis();
 
1140
                }
 
1141
 
 
1142
                long timeSinceLastPacket = (System.currentTimeMillis() - lastPacketSentTimeMs) / 1000;
 
1143
 
 
1144
                int dueToTimeout = DUE_TO_TIMEOUT_FALSE;
 
1145
 
 
1146
                StringBuffer timeoutMessageBuf = null;
 
1147
 
 
1148
                if (streamingResultSetInPlay) {
 
1149
                        exceptionMessageBuf.append(Messages
 
1150
                                        .getString("CommunicationsException.ClientWasStreaming")); //$NON-NLS-1$
 
1151
                } else {
 
1152
                        if (serverTimeoutSeconds != 0) {
 
1153
                                if (timeSinceLastPacket > serverTimeoutSeconds) {
 
1154
                                        dueToTimeout = DUE_TO_TIMEOUT_TRUE;
 
1155
 
 
1156
                                        timeoutMessageBuf = new StringBuffer();
 
1157
 
 
1158
                                        timeoutMessageBuf.append(Messages
 
1159
                                                        .getString("CommunicationsException.2")); //$NON-NLS-1$
 
1160
 
 
1161
                                        if (!isInteractiveClient) {
 
1162
                                                timeoutMessageBuf.append(Messages
 
1163
                                                                .getString("CommunicationsException.3")); //$NON-NLS-1$
 
1164
                                        } else {
 
1165
                                                timeoutMessageBuf.append(Messages
 
1166
                                                                .getString("CommunicationsException.4")); //$NON-NLS-1$
 
1167
                                        }
 
1168
 
 
1169
                                }
 
1170
                        } else if (timeSinceLastPacket > DEFAULT_WAIT_TIMEOUT_SECONDS) {
 
1171
                                dueToTimeout = DUE_TO_TIMEOUT_MAYBE;
 
1172
 
 
1173
                                timeoutMessageBuf = new StringBuffer();
 
1174
 
 
1175
                                timeoutMessageBuf.append(Messages
 
1176
                                                .getString("CommunicationsException.5")); //$NON-NLS-1$
 
1177
                                timeoutMessageBuf.append(Messages
 
1178
                                                .getString("CommunicationsException.6")); //$NON-NLS-1$
 
1179
                                timeoutMessageBuf.append(Messages
 
1180
                                                .getString("CommunicationsException.7")); //$NON-NLS-1$
 
1181
                                timeoutMessageBuf.append(Messages
 
1182
                                                .getString("CommunicationsException.8")); //$NON-NLS-1$
 
1183
                        }
 
1184
 
 
1185
                        if (dueToTimeout == DUE_TO_TIMEOUT_TRUE
 
1186
                                        || dueToTimeout == DUE_TO_TIMEOUT_MAYBE) {
 
1187
 
 
1188
                                exceptionMessageBuf.append(Messages
 
1189
                                                .getString("CommunicationsException.9")); //$NON-NLS-1$
 
1190
                                exceptionMessageBuf.append(timeSinceLastPacket);
 
1191
                                exceptionMessageBuf.append(Messages
 
1192
                                                .getString("CommunicationsException.10")); //$NON-NLS-1$
 
1193
 
 
1194
                                if (timeoutMessageBuf != null) {
 
1195
                                        exceptionMessageBuf.append(timeoutMessageBuf);
 
1196
                                }
 
1197
 
 
1198
                                exceptionMessageBuf.append(Messages
 
1199
                                                .getString("CommunicationsException.11")); //$NON-NLS-1$
 
1200
                                exceptionMessageBuf.append(Messages
 
1201
                                                .getString("CommunicationsException.12")); //$NON-NLS-1$
 
1202
                                exceptionMessageBuf.append(Messages
 
1203
                                                .getString("CommunicationsException.13")); //$NON-NLS-1$
 
1204
 
 
1205
                        } else {
 
1206
                                //
 
1207
                                // Attempt to determine the reason for the underlying exception
 
1208
                                // (we can only make a best-guess here)
 
1209
                                //
 
1210
 
 
1211
                                if (underlyingException instanceof BindException) {
 
1212
                                        if (conn.getLocalSocketAddress() != null
 
1213
                                                        && !Util.interfaceExists(conn
 
1214
                                                                        .getLocalSocketAddress())) {
 
1215
                                                exceptionMessageBuf.append(Messages
 
1216
                                                                .getString("CommunicationsException.19a")); //$NON-NLS-1$
 
1217
                                        } else {
 
1218
                                                // too many client connections???
 
1219
                                                exceptionMessageBuf.append(Messages
 
1220
                                                                .getString("CommunicationsException.14")); //$NON-NLS-1$
 
1221
                                                exceptionMessageBuf.append(Messages
 
1222
                                                                .getString("CommunicationsException.15")); //$NON-NLS-1$
 
1223
                                                exceptionMessageBuf.append(Messages
 
1224
                                                                .getString("CommunicationsException.16")); //$NON-NLS-1$
 
1225
                                                exceptionMessageBuf.append(Messages
 
1226
                                                                .getString("CommunicationsException.17")); //$NON-NLS-1$
 
1227
                                                exceptionMessageBuf.append(Messages
 
1228
                                                                .getString("CommunicationsException.18")); //$NON-NLS-1$
 
1229
                                                exceptionMessageBuf.append(Messages
 
1230
                                                                .getString("CommunicationsException.19")); //$NON-NLS-1$
 
1231
                                        }
 
1232
                                }
 
1233
                        }
 
1234
                }
 
1235
 
 
1236
                if (exceptionMessageBuf.length() == 0) {
 
1237
                        // We haven't figured out a good reason, so copy it.
 
1238
                        exceptionMessageBuf.append(Messages
 
1239
                                        .getString("CommunicationsException.20")); //$NON-NLS-1$
 
1240
 
 
1241
                        if (THROWABLE_INIT_CAUSE_METHOD == null && 
 
1242
                                        underlyingException != null) {
 
1243
                                exceptionMessageBuf.append(Messages
 
1244
                                                .getString("CommunicationsException.21")); //$NON-NLS-1$
 
1245
                                exceptionMessageBuf.append(Util
 
1246
                                                .stackTraceToString(underlyingException));
 
1247
                        }
 
1248
 
 
1249
                        if (conn != null && conn.getMaintainTimeStats()
 
1250
                                        && !conn.getParanoid()) {
 
1251
                                exceptionMessageBuf
 
1252
                                                .append("\n\nLast packet sent to the server was ");
 
1253
                                exceptionMessageBuf.append(System.currentTimeMillis()
 
1254
                                                - lastPacketSentTimeMs);
 
1255
                                exceptionMessageBuf.append(" ms ago.");
 
1256
                        }
 
1257
                }
 
1258
                
 
1259
                return exceptionMessageBuf.toString();
947
1260
        }
948
1261
}