Skip to content

Commit

Permalink
feat: add get database name
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-kbys committed Jun 4, 2024
1 parent e013f37 commit 9aa96ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ protected void doBegin(JdbcOutputConnection con,
}
}
}
task.setActualTable(new TableIdentifier(null, con.getSchemaName(), actualTable));
task.setActualTable(new TableIdentifier(con.getDatabaseName(), con.getSchemaName(), actualTable));

Optional<JdbcSchema> initialTargetTableSchema =
mode.ignoreTargetTableSchema() ?
Expand Down Expand Up @@ -999,6 +999,9 @@ public Optional<JdbcSchema> newJdbcSchemaFromTableIfExists(JdbcOutputConnection
final Set<String> primaryKeys = Collections.unmodifiableSet(primaryKeysBuilder);

final ArrayList<JdbcColumn> builder = new ArrayList<>();
logger.info("table database: {}", table.getDatabase());
logger.info("table schema: {}", table.getSchemaName());
logger.info("table name: {}", table.getTableName());
rs = dbm.getColumns(
JdbcUtils.escapeSearchString(table.getDatabase(), escape),
JdbcUtils.escapeSearchString(table.getSchemaName(), escape),
Expand All @@ -1007,6 +1010,7 @@ public Optional<JdbcSchema> newJdbcSchemaFromTableIfExists(JdbcOutputConnection
try {
while (rs.next()) {
String columnName = rs.getString("COLUMN_NAME");
logger.info("column name {}", columnName);
String simpleTypeName = rs.getString("TYPE_NAME").toUpperCase(Locale.ENGLISH);
boolean isUniqueKey = primaryKeys.contains(columnName);
int sqlType = rs.getInt("DATA_TYPE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public void close() throws SQLException
}
}

public String getDatabaseName() throws SQLException
{
return connection.getCatalog();
}

public String getSchemaName()
{
return schemaName;
Expand Down

0 comments on commit 9aa96ac

Please sign in to comment.