Browse Source

fix: cursor over limit when sync (#114)

* fix: cursor over limit when sync

* fix: code checkstyle
master
vran 3 years ago
committed by GitHub
parent
commit
137923c740
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      api/src/main/java/com/databasir/api/Routes.java
  2. 6
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java
  3. 6
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java
  4. 6
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java
  5. 7
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java

2
api/src/main/java/com/databasir/api/Routes.java

@ -169,6 +169,8 @@ public interface Routes {
String CREATE = BASE + "/database_types";
String RESOLVE_DRIVER_CLASS_NAME = BASE + "/database_types/driver_class_name";
String UPLOAD_DRIVER = BASE + "/database_types/upload_driver";
}
interface MockData {

6
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java

@ -36,9 +36,10 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
columnsResult = connection.getMetaData()
.getColumns(databaseName, tableCondition.getSchemaName(), tableName, null);
} catch (SQLException e) {
log.warn("warn: ignore columns in " + databaseName + "." + tableName);
log.warn("warn: ignore columns in " + databaseName + "." + tableName + ", error: " + e.getMessage());
return columnDocs;
}
try {
while (columnsResult.next()) {
String columnName = columnsResult.getString("COLUMN_NAME");
if (tableCondition.columnIsIgnored(columnName)) {
@ -83,6 +84,9 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
columnDocs.add(columnMeta);
}
}
} finally {
columnsResult.close();
}
return columnDocs;
}

6
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java

@ -50,6 +50,12 @@ public class JdbcForeignKeyMetaRepository implements ForeignKeyMetaRepository {
}
} catch (SQLException e) {
log.warn("warn: ignore foreign keys in " + databaseName + "." + tableName + ", " + e.getMessage());
} finally {
try {
keyResult.close();
} catch (SQLException e) {
log.warn("warn: close key result error " + databaseName + "." + tableName + ", " + e.getMessage());
}
}
return foreignKeys;
}

6
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java

@ -31,11 +31,12 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository {
indexResults = connection.getMetaData()
.getIndexInfo(databaseName, condition.getSchemaName(), tableName, false, false);
} catch (SQLException e) {
log.warn("warn: ignore " + databaseName + "." + tableName);
log.warn("warn: ignore " + databaseName + "." + tableName + ", error=" + e.getMessage());
return indexMetas;
}
Map<String, IndexMeta> pojoGroupByName = new HashMap<>();
try {
while (indexResults.next()) {
Boolean nonUnique = indexResults.getBoolean("NON_UNIQUE");
String indexName = indexResults.getString("INDEX_NAME");
@ -53,6 +54,9 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository {
pojoGroupByName.put(indexName, indexMeta);
}
}
} finally {
indexResults.close();
}
return new ArrayList<>(pojoGroupByName.values());
}

7
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java

@ -40,6 +40,7 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
String databaseName = condition.getDatabaseName();
ResultSet tablesResult = connection.getMetaData()
.getTables(databaseName, condition.getSchemaName(), null, new String[]{"TABLE"});
try {
while (tablesResult.next()) {
String tableName = tablesResult.getString("TABLE_NAME");
if (condition.tableIsIgnored(tableName)) {
@ -53,7 +54,8 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
List<ColumnMeta> columns = columnMetaRepository.selectColumns(connection, tableCondition);
if (columns.isEmpty()) {
if (log.isWarnEnabled()) {
log.warn("ignored table: " + databaseName + "." + tableName + ", caused by get empty columns");
log.warn("ignored table: " + databaseName + "." + tableName
+ ", caused by get empty columns");
}
continue;
}
@ -69,6 +71,9 @@ public class JdbcTableMetaRepository implements TableMetaRepository {
tableMetas.add(tableMeta);
}
}
} finally {
tablesResult.close();
}
return tableMetas;
}

Loading…
Cancel
Save