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

更新url 和 Driver

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