XiaoJiang521 commented on code in PR #5096:
URL: https://github.com/apache/seatunnel/pull/5096#discussion_r1286702558
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/sqlserver/SqlServerCatalog.java:
##########
@@ -292,99 +184,27 @@ private SeaTunnelDataType<?> fromJdbcType(String
typeName, int precision, int sc
}
@Override
- protected boolean createTableInternal(TablePath tablePath, CatalogTable
table)
- throws CatalogException {
-
- String createTableSql =
- SqlServerCreateTableSqlBuilder.builder(tablePath,
table).build(tablePath, table);
- log.info("create table sql: {}", createTableSql);
- try (Connection conn = DriverManager.getConnection(defaultUrl,
username, pwd);
- PreparedStatement ps = conn.prepareStatement(createTableSql)) {
- System.out.println(createTableSql);
- return ps.execute();
- } catch (Exception e) {
- throw new CatalogException(
- String.format("Failed creating table %s",
tablePath.getFullName()), e);
- }
+ protected String getCreateTableSql(TablePath tablePath, CatalogTable
table) {
+ return SqlServerCreateTableSqlBuilder.builder(tablePath,
table).build(tablePath, table);
}
@Override
- protected boolean dropTableInternal(TablePath tablePath) throws
CatalogException {
- String dbUrl = getUrlFromDatabaseName(tablePath.getDatabaseName());
- try (Connection conn = DriverManager.getConnection(dbUrl, username,
pwd);
- PreparedStatement ps =
- conn.prepareStatement(
- String.format(
- "DROP TABLE IF EXISTS %s",
tablePath.getFullName()))) {
- // Will there exist concurrent drop for one table?
- return ps.execute();
- } catch (SQLException e) {
- throw new CatalogException(
- String.format("Failed dropping table %s",
tablePath.getFullName()), e);
- }
+ protected String getDropTableSql(TablePath tablePath) {
+ return String.format("DROP TABLE IF EXISTS %s",
tablePath.getFullName());
}
@Override
- protected boolean createDatabaseInternal(String databaseName) throws
CatalogException {
- try (Connection conn = DriverManager.getConnection(defaultUrl,
username, pwd);
- PreparedStatement ps =
- conn.prepareStatement(
- String.format("CREATE DATABASE `%s`",
databaseName))) {
- return ps.execute();
- } catch (Exception e) {
- throw new CatalogException(
- String.format(
- "Failed creating database %s in catalog %s",
- databaseName, this.catalogName),
- e);
- }
+ protected String getCreateDatabaseSql(String databaseName) {
+ return String.format("CREATE DATABASE `%s`", databaseName);
Review Comment:
Yes, this is a historical bug. Thank you for your effort.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]