whhe commented on code in PR #5096:
URL: https://github.com/apache/seatunnel/pull/5096#discussion_r1286673270


##########
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:
   I just copied the sql templates from 
https://github.com/apache/seatunnel/blob/dev/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/sqlserver/SqlServerCatalog.java
   
   Will fix it later.



-- 
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]

Reply via email to