[jOOQ/jOOQ#14701] Let DataAccessException::sqlStateClass be based on SQL Server error codes for SQLStateClass 22 or 23

This commit is contained in:
Lukas Eder 2023-02-24 12:51:27 +01:00
parent 5ebcc5c053
commit 94af3fdd98
2 changed files with 68 additions and 0 deletions

View File

@ -45,6 +45,8 @@ import java.sql.SQLIntegrityConstraintViolationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
// ...
import io.r2dbc.spi.R2dbcException;
/**
@ -139,6 +141,22 @@ public class DataAccessException extends RuntimeException {
*/
@NotNull
public static SQLStateClass sqlStateClass(SQLException e) {
if (e.getSQLState() != null)
return SQLStateClass.fromCode(e.getSQLState());
else if (e.getSQLState() == null && "org.sqlite.SQLiteException".equals(e.getClass().getName()))

View File

@ -40,6 +40,8 @@ package org.jooq.exception;
import java.util.HashMap;
import java.util.Map;
// ...
import org.jetbrains.annotations.NotNull;
/**
@ -198,4 +200,52 @@ public enum SQLStateClass {
return SQLStateClass.OTHER;
}
}