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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
103 additions and
82 deletions
-
api/src/main/java/com/databasir/api/Routes.java
-
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java
-
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java
-
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java
-
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.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 { |
|
|
|
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
@ -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()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|