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