|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -17,7 +17,6 @@ |
|
|
|
package org.springframework.jdbc.support; |
|
|
|
package org.springframework.jdbc.support; |
|
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.dao.ConcurrencyFailureException; |
|
|
|
import org.springframework.dao.ConcurrencyFailureException; |
|
|
|
@ -46,45 +45,42 @@ import org.springframework.lang.Nullable; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator { |
|
|
|
public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator { |
|
|
|
|
|
|
|
|
|
|
|
private static final Set<String> BAD_SQL_GRAMMAR_CODES = new HashSet<>(8); |
|
|
|
private static final Set<String> BAD_SQL_GRAMMAR_CODES = Set.of( |
|
|
|
|
|
|
|
"07", // Dynamic SQL error
|
|
|
|
private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = new HashSet<>(8); |
|
|
|
"21", // Cardinality violation
|
|
|
|
|
|
|
|
"2A", // Syntax error direct SQL
|
|
|
|
private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<>(8); |
|
|
|
"37", // Syntax error dynamic SQL
|
|
|
|
|
|
|
|
"42", // General SQL syntax error
|
|
|
|
private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<>(8); |
|
|
|
"65" // Oracle: unknown identifier
|
|
|
|
|
|
|
|
); |
|
|
|
private static final Set<String> CONCURRENCY_FAILURE_CODES = new HashSet<>(4); |
|
|
|
|
|
|
|
|
|
|
|
private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = Set.of( |
|
|
|
|
|
|
|
"01", // Data truncation
|
|
|
|
static { |
|
|
|
"02", // No data found
|
|
|
|
BAD_SQL_GRAMMAR_CODES.add("07"); // Dynamic SQL error
|
|
|
|
"22", // Value out of range
|
|
|
|
BAD_SQL_GRAMMAR_CODES.add("21"); // Cardinality violation
|
|
|
|
"23", // Integrity constraint violation
|
|
|
|
BAD_SQL_GRAMMAR_CODES.add("2A"); // Syntax error direct SQL
|
|
|
|
"27", // Triggered data change violation
|
|
|
|
BAD_SQL_GRAMMAR_CODES.add("37"); // Syntax error dynamic SQL
|
|
|
|
"44" // With check violation
|
|
|
|
BAD_SQL_GRAMMAR_CODES.add("42"); // General SQL syntax error
|
|
|
|
); |
|
|
|
BAD_SQL_GRAMMAR_CODES.add("65"); // Oracle: unknown identifier
|
|
|
|
|
|
|
|
|
|
|
|
private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = Set.of( |
|
|
|
DATA_INTEGRITY_VIOLATION_CODES.add("01"); // Data truncation
|
|
|
|
"08", // Connection exception
|
|
|
|
DATA_INTEGRITY_VIOLATION_CODES.add("02"); // No data found
|
|
|
|
"53", // PostgreSQL: insufficient resources (e.g. disk full)
|
|
|
|
DATA_INTEGRITY_VIOLATION_CODES.add("22"); // Value out of range
|
|
|
|
"54", // PostgreSQL: program limit exceeded (e.g. statement too complex)
|
|
|
|
DATA_INTEGRITY_VIOLATION_CODES.add("23"); // Integrity constraint violation
|
|
|
|
"57", // DB2: out-of-memory exception / database not started
|
|
|
|
DATA_INTEGRITY_VIOLATION_CODES.add("27"); // Triggered data change violation
|
|
|
|
"58" // DB2: unexpected system error
|
|
|
|
DATA_INTEGRITY_VIOLATION_CODES.add("44"); // With check violation
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
DATA_ACCESS_RESOURCE_FAILURE_CODES.add("08"); // Connection exception
|
|
|
|
private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = Set.of( |
|
|
|
DATA_ACCESS_RESOURCE_FAILURE_CODES.add("53"); // PostgreSQL: insufficient resources (e.g. disk full)
|
|
|
|
"JW", // Sybase: internal I/O error
|
|
|
|
DATA_ACCESS_RESOURCE_FAILURE_CODES.add("54"); // PostgreSQL: program limit exceeded (e.g. statement too complex)
|
|
|
|
"JZ", // Sybase: unexpected I/O error
|
|
|
|
DATA_ACCESS_RESOURCE_FAILURE_CODES.add("57"); // DB2: out-of-memory exception / database not started
|
|
|
|
"S1" // DB2: communication failure
|
|
|
|
DATA_ACCESS_RESOURCE_FAILURE_CODES.add("58"); // DB2: unexpected system error
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("JW"); // Sybase: internal I/O error
|
|
|
|
private static final Set<String> CONCURRENCY_FAILURE_CODES = Set.of( |
|
|
|
TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("JZ"); // Sybase: unexpected I/O error
|
|
|
|
"40", // Transaction rollback
|
|
|
|
TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("S1"); // DB2: communication failure
|
|
|
|
"61" // Oracle: deadlock
|
|
|
|
|
|
|
|
); |
|
|
|
CONCURRENCY_FAILURE_CODES.add("40"); // Transaction rollback
|
|
|
|
|
|
|
|
CONCURRENCY_FAILURE_CODES.add("61"); // Oracle: deadlock
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|