Java Spring JDBC-Kafka消费者的可重试异常

Java Spring JDBC-Kafka消费者的可重试异常,java,spring,spring-jdbc,kafka-consumer-api,spring-kafka,Java,Spring,Spring Jdbc,Kafka Consumer Api,Spring Kafka,我正在使用Spring Kafka消费者阅读有关Kafka主题的消息。我正在Oracle DB中持久化这些。每当出现数据库连接错误时,我都希望执行重试。我正在使用Spring JDBC连接到oracle DB。如果我需要执行仅重试JDBC连接问题,我需要添加哪些异常类列表 private static Map<Class<? extends Throwable>, Boolean> retryableExceptions; static{ retryableEx

我正在使用Spring Kafka消费者阅读有关Kafka主题的消息。我正在Oracle DB中持久化这些。每当出现数据库连接错误时,我都希望执行重试。我正在使用Spring JDBC连接到oracle DB。如果我需要执行仅重试JDBC连接问题,我需要添加哪些异常类列表

private static Map<Class<? extends Throwable>, Boolean> retryableExceptions;

static{
    retryableExceptions = new HashMap<>();
    retryableExceptions.put(Exception.class, true);
}
protected RetryPolicy retryPolicy() {
        SimpleRetryPolicy policy = new SimpleRetryPolicy(maxRetryAttempts, retryableExceptions);
        return policy;
}

private static Map我想您只需要这个:

/**
 * Data access exception thrown when a resource fails completely:
 * for example, if we can't connect to a database using JDBC.
 *
 * @author Rod Johnson
 * @author Thomas Risberg
 */
@SuppressWarnings("serial")
public class DataAccessResourceFailureException extends NonTransientDataAccessResourceException {
只要使用
JdbcTemplate
执行JDBC操作,连接中的任何低级错误都会被包装到此
DataAccessResourceFailureException
或其子类中