mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 04:59:51 +08:00
Merge pull request #2074 from xieruiming/fix_conn
postSql use DriverManager to get connection
This commit is contained in:
commit
072b24f673
@ -191,6 +191,7 @@ public class BaseWriter {
|
||||
// 一般来说,是需要推迟到 task 中进行post 的执行(单表情况例外)
|
||||
public void post(Configuration originalConfig) {
|
||||
|
||||
try {
|
||||
String username = originalConfig.getString(Key.USERNAME);
|
||||
String password = originalConfig.getString(Key.PASSWORD);
|
||||
|
||||
@ -207,16 +208,17 @@ public class BaseWriter {
|
||||
// 说明有 postSql 配置,则此处删除掉
|
||||
originalConfig.remove(Key.POST_SQL);
|
||||
String tempJdbcUrl = jdbcUrl.replace("postgresql", "hologres");
|
||||
Connection conn = DBUtil.getConnection(this.dataBaseType,
|
||||
tempJdbcUrl, username, password);
|
||||
|
||||
try (Connection conn = DriverManager.getConnection(
|
||||
tempJdbcUrl, username, password)) {
|
||||
LOG.info(
|
||||
"Begin to execute postSqls:[{}]. context info:{}.",
|
||||
StringUtils.join(renderedPostSqls, ";"), tempJdbcUrl);
|
||||
WriterUtil.executeSqls(conn, renderedPostSqls, tempJdbcUrl, dataBaseType);
|
||||
DBUtil.closeDBResources(null, null, conn);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw DataXException.asDataXException(DBUtilErrorCode.SQL_EXECUTE_FAIL, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy(Configuration originalConfig) {
|
||||
|
Loading…
Reference in New Issue
Block a user