cn.vonce.sql.spring.datasource.DataSourceContextHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vonce-sqlbean-spring Show documentation
Show all versions of vonce-sqlbean-spring Show documentation
This is a tool that uses java object-oriented idea to write and generate SQL statements. On this basis,
it also implements lightweight plug-in support similar to JPA for mybatis and spring JDBC. A large number of
common SQL execution methods are built in plug-ins to improve development efficiency, reduce a large number of
SQL statement writing, and make developers focus on business code writing.
The newest version!
package cn.vonce.sql.spring.datasource;
/**
* 数据持有者
*
* @author Jovi
* @version 1.0
* @email [email protected]
* @date 2020/10/29 21:21
*/
public class DataSourceContextHolder {
private static final ThreadLocal contextHolder = new ThreadLocal<>();
/**
* 设置当前数据源
*
* @param dataSource
*/
public static void setDataSource(String dataSource) {
contextHolder.set(dataSource);
}
/**
* 根据获取源
*
* @return
*/
public static String getDataSource() {
return contextHolder.get();
}
/**
* 清除数据源
*/
public static void clearDataSource() {
contextHolder.remove();
}
}