Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: remove mysql dependency from the distribution package #6332

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6330](https://github.com/apache/incubator-seata/pull/6330)] remove mariadb API
- [[#6329](https://github.com/apache/incubator-seata/pull/6312)] add saga subcomponent-level io.seata compatible api
- [[#6254](https://github.com/apache/incubator-seata/pull/6254)] optimize Hessian Serialize
- [[#6332](https://github.com/apache/incubator-seata/pull/6332)] remove mysql dependency from the distribution package
- [[#6343](https://github.com/apache/incubator-seata/pull/6343)] compatible with tm module and rm-datasource module

### security:
Expand Down
2 changes: 1 addition & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
- [[#6330](https://github.com/apache/incubator-seata/pull/6330)] 去除 mariadb API
- [[#6329](https://github.com/apache/incubator-seata/pull/6312)] 添加saga子组件的io.seata兼容性API
- [[#6254](https://github.com/apache/incubator-seata/pull/6254)] 优化Hessian 序列化
- [[#6332](https://github.com/apache/incubator-seata/pull/6332)] 分发包中移除 mysql 依赖
- [[#6343](https://github.com/apache/incubator-seata/pull/6343)] 兼容tm 模块和rm-datasource模块



### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
- [[#6144](https://github.com/apache/incubator-seata/pull/6144)] 升级Nacos依赖版本至1.4.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import java.util.Map;
import java.util.Objects;
import java.util.stream.Stream;

import javax.sql.DataSource;

import org.apache.seata.common.exception.StoreException;
import org.apache.seata.common.executor.Initialize;
import org.apache.seata.common.util.ConfigTools;
Expand Down Expand Up @@ -78,11 +80,36 @@ public DataSource provide() {
return this.dataSource;
}

public DataSource generate() {
validate();
return doGenerate();
}

public void validate() {
//valid driver class name
String driverClassName = getDriverClassName();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (null == loader) {
throw new StoreException("class loader set error, you should not use the Bootstrap classloader");
}
try {
loader.loadClass(driverClassName);
} catch (ClassNotFoundException exx) {
String driverClassPath = null;
String folderPath = System.getProperty("loader.path");
if (null != folderPath) {
driverClassPath = folderPath + "/jdbc/";
}
throw new StoreException(String.format(
"the {%s} can't be found in the path %s, please copy database driver dependencies, such as `mysql-connector-java.jar` to the path.", driverClassName, driverClassPath));
}

}
/**
* generate the datasource
* @return datasource
*/
public abstract DataSource generate();
public abstract DataSource doGenerate();

/**
* Get db type db type.
Expand Down
Loading
Loading