提交 0beb4069 authored 作者: 王红亮's avatar 王红亮

更新url 和 Driver

上级 51e95d4a
......@@ -21,7 +21,6 @@ import org.apache.seatunnel.api.configuration.util.OptionRule;
import org.apache.seatunnel.datasource.plugin.api.DataSourceChannelExt;
import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginException;
import org.apache.seatunnel.datasource.plugin.api.model.TableField;
import org.apache.seatunnel.datasource.plugin.api.utils.JdbcUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -195,9 +194,20 @@ public class PostgresqlDataSourceChannel implements DataSourceChannelExt {
throws SQLException, ClassNotFoundException {
checkNotNull(requestParams.get(PostgresqlOptionRule.DRIVER.key()));
checkNotNull(requestParams.get(PostgresqlOptionRule.URL.key()), "Jdbc url cannot be null");
String url =
JdbcUtils.replaceDatabase(
requestParams.get(PostgresqlOptionRule.URL.key()), databaseName);
String url = requestParams.get(PostgresqlOptionRule.URL.key());
String driver = requestParams.get(PostgresqlOptionRule.DRIVER.key());
if (StringUtils.isEmpty(driver)) {
driver = "org.postgresql.Driver";
}
Class Clazz = Class.forName(driver);
Driver driverInstance = null;
try {
driverInstance = (Driver) Clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
DriverManager.registerDriver(driverInstance);
if (requestParams.containsKey(PostgresqlOptionRule.USER.key())) {
String username = requestParams.get(PostgresqlOptionRule.USER.key());
String password = requestParams.get(PostgresqlOptionRule.PASSWORD.key());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论