-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
207 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/main/java/com/firebolt/jdbc/exception/SQLState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package com.firebolt.jdbc.exception; | ||
|
||
import java.util.EnumSet; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
// https://en.wikipedia.org/wiki/SQLSTATE | ||
public enum SQLState { | ||
SUCCESS("00000"), | ||
WARNING("01000"), | ||
NO_DATA("02000"), | ||
STATEMENT_STRING_DATA_RIGHT_TRUNCATION("01004"), | ||
NULL_VALUE_NO_INDICATOR_PARAMETER("22002"), | ||
CONNECTION_EXCEPTION("08001"), | ||
CONNECTION_DOES_NOT_EXIST("08003"), | ||
CONNECTION_FAILURE("08006"), | ||
TRANSACTION_RESOLUTION_UNKNOWN("08007"), | ||
SQL_SYNTAX_ERROR("42000"), | ||
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION("42601"), | ||
DUPLICATE_KEY_VALUE("23505"), | ||
DATA_EXCEPTION("22000"), | ||
CHARACTER_NOT_IN_REPERTOIRE("22021"), | ||
STRING_DATA_RIGHT_TRUNCATION("22001"), | ||
NUMERIC_VALUE_OUT_OF_RANGE("22003"), | ||
INVALID_DATETIME_FORMAT("22007"), | ||
INVALID_TIME_ZONE_DISPLACEMENT_VALUE("22009"), | ||
INVALID_ESCAPE_CHARACTER("22019"), | ||
INVALID_PARAMETER_VALUE("22023"), | ||
INVALID_CURSOR_STATE("24000"), | ||
INVALID_TRANSACTION_STATE("25000"), | ||
INVALID_AUTHORIZATION_SPECIFICATION("28000"), | ||
INVALID_SQL_STATEMENT_NAME("26000"), | ||
INVALID_CURSOR_NAME("34000"), | ||
INVALID_SCHEMA_NAME("3F000"), | ||
TRANSACTION_ROLLBACK("40000"), | ||
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION_IN_DIRECT_STATEMENT("2F000"), | ||
INVALID_SQL_DESCRIPTOR_NAME("33000"), | ||
INVALID_CURSOR_POSITION("34000"), | ||
INVALID_CONDITION_NUMBER("35000"), | ||
INVALID_TRANSACTION_TERMINATION("2D000"), | ||
INVALID_CONNECTION_NAME("2E000"), | ||
INVALID_AUTHORIZATION_NAME("28000"), | ||
INVALID_COLUMN_NAME("42703"), | ||
INVALID_COLUMN_DEFINITION("42P16"), | ||
INVALID_CURSOR_DEFINITION("42P11"), | ||
INVALID_DATABASE_DEFINITION("42P15"), | ||
INVALID_FUNCTION_DEFINITION("42P13"), | ||
INVALID_PREPARED_STATEMENT_DEFINITION("42P12"), | ||
INVALID_SCHEMA_DEFINITION("42P14"), | ||
INVALID_TABLE_DEFINITION("42P01"), | ||
INVALID_OBJECT_DEFINITION("42P17"), | ||
WITH_CHECK_OPTION_VIOLATION("44000"), | ||
INSUFFICIENT_RESOURCES("53000"), | ||
DISK_FULL("53100"), | ||
OUT_OF_MEMORY("53200"), | ||
TOO_MANY_CONNECTIONS("53300"), | ||
CONFIGURATION_LIMIT_EXCEEDED("53400"), | ||
PROGRAM_LIMIT_EXCEEDED("54000"), | ||
OBJECT_NOT_IN_PREREQUISITE_STATE("55000"), | ||
OBJECT_IN_USE("55006"), | ||
CANT_CHANGE_RUNTIME_PARAM("55P02"), | ||
LOCK_NOT_AVAILABLE("55P03"), | ||
OPERATOR_INTERVENTION("57000"), | ||
QUERY_CANCELED("57014"), | ||
ADMIN_SHUTDOWN("57P01"), | ||
CRASH_SHUTDOWN("57P02"), | ||
CANNOT_CONNECT_NOW("57P03"), | ||
DATABASE_DROPPED("57P04"), | ||
SYSTEM_ERROR("58000"), | ||
IO_ERROR("58030"), | ||
UNDEFINED_FILE("58P01"), | ||
DUPLICATE_FILE("58P02"), | ||
SNAPSHOT_TOO_OLD("72000"), | ||
CONFIGURATION_FILE_ERROR("F0000"), | ||
LOCK_FILE_EXISTS("F0001"), | ||
FDW_ERROR("HV000"), | ||
FDW_COLUMN_NAME_NOT_FOUND("HV005"), | ||
FDW_DYNAMIC_PARAMETER_VALUE_NEEDED("HV002"), | ||
FDW_FUNCTION_SEQUENCE_ERROR("HV010"), | ||
FDW_INCONSISTENT_DESCRIPTOR_INFORMATION("HV021"), | ||
FDW_INVALID_ATTRIBUTE_VALUE("HV024"), | ||
FDW_INVALID_COLUMN_NAME("HV007"), | ||
FDW_INVALID_COLUMN_NUMBER("HV008"), | ||
FDW_INVALID_DATA_TYPE("HV004"), | ||
FDW_INVALID_DATA_TYPE_DESCRIPTORS("HV006"), | ||
FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER("HV091"), | ||
FDW_INVALID_HANDLE("HV00B"), | ||
FDW_INVALID_OPTION_INDEX("HV00C"), | ||
FDW_INVALID_OPTION_NAME("HV00D"), | ||
FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH("HV090"), | ||
FDW_INVALID_STRING_FORMAT("HV00A"), | ||
FDW_INVALID_USE_OF_NULL_POINTER("HV009"), | ||
FDW_TOO_MANY_HANDLES("HV014"), | ||
FDW_OUT_OF_MEMORY("HV001"), | ||
FDW_NO_SCHEMAS("HV00P"), | ||
FDW_OPTION_NAME_NOT_FOUND("HV00J"), | ||
FDW_REPLY_HANDLE("HV00K"), | ||
FDW_SCHEMA_NOT_FOUND("HV00Q"), | ||
FDW_TABLE_NOT_FOUND("HV00R"), | ||
FDW_UNABLE_TO_CREATE_EXECUTION("HV00L"), | ||
FDW_UNABLE_TO_CREATE_REPLY("HV00M"), | ||
FDW_UNABLE_TO_ESTABLISH_CONNECTION("HV00N"), | ||
PLPGSQL_ERROR("P0000"), | ||
RAISE_EXCEPTION("P0001"), | ||
NO_DATA_FOUND("P0002"), | ||
TOO_MANY_ROWS("P0003"), | ||
ASSERT_FAILURE("P0004"), | ||
INTERNAL_ERROR("XX000"), | ||
DATA_CORRUPTED("XX001"), | ||
INDEX_CORRUPTED("XX002"), | ||
STATE_NOT_DEFINED(null); | ||
|
||
private final String code; | ||
private static final Map<String, SQLState> codeMap = new HashMap<>(); | ||
static { | ||
for (SQLState s : EnumSet.allOf(SQLState.class)) | ||
codeMap.put(s.getCode(), s); | ||
} | ||
|
||
SQLState(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public static SQLState fromCode(String sqlState) { | ||
return codeMap.get(sqlState); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters