|
|
|
|
@ -16,6 +16,8 @@
@@ -16,6 +16,8 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.r2dbc.connection; |
|
|
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
import io.r2dbc.spi.Connection; |
|
|
|
|
import io.r2dbc.spi.ConnectionFactory; |
|
|
|
|
import io.r2dbc.spi.R2dbcBadGrammarException; |
|
|
|
|
@ -69,6 +71,14 @@ public abstract class ConnectionFactoryUtils {
@@ -69,6 +71,14 @@ public abstract class ConnectionFactoryUtils {
|
|
|
|
|
*/ |
|
|
|
|
public static final int CONNECTION_SYNCHRONIZATION_ORDER = 1000; |
|
|
|
|
|
|
|
|
|
private static final Set<Integer> DUPLICATE_KEY_ERROR_CODES = Set.of( |
|
|
|
|
1, // Oracle
|
|
|
|
|
301, // Sap Hana
|
|
|
|
|
1062, // MySQL/MariaDB
|
|
|
|
|
2601, // MS SQL Server
|
|
|
|
|
2627 // MS SQL Server
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Obtain a {@link Connection} from the given {@link ConnectionFactory}. |
|
|
|
|
@ -255,8 +265,7 @@ public abstract class ConnectionFactoryUtils {
@@ -255,8 +265,7 @@ public abstract class ConnectionFactoryUtils {
|
|
|
|
|
*/ |
|
|
|
|
static boolean indicatesDuplicateKey(@Nullable String sqlState, int errorCode) { |
|
|
|
|
return ("23505".equals(sqlState) || |
|
|
|
|
("23000".equals(sqlState) && |
|
|
|
|
(errorCode == 1 || errorCode == 1062 || errorCode == 2601 || errorCode == 2627))); |
|
|
|
|
("23000".equals(sqlState) && DUPLICATE_KEY_ERROR_CODES.contains(errorCode))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|