package com.ruoyi.system.test;

import java.sql.Connection;
import java.sql.SQLException;

public class DynamicDataSourceContext {
    private ThreadLocal<String> dataSourceNameThreadLocal;

    public DynamicDataSourceContext() {
        dataSourceNameThreadLocal = new ThreadLocal<>();
    }

    // 设置当前线程的数据源标识
    public void setDataSourceName(String name) {
        dataSourceNameThreadLocal.set(name);
    }

    // 清除当前线程的数据源标识
    public void clearDataSourceName() {
        dataSourceNameThreadLocal.remove();
    }
}